1 测试代码 1-1 写入代码 1-2 读取代码 2 源码分析 2-1createweight 2-1-1 TermQuery构造weight 2-1-2 MultiTermQueryConstantScoreWrapper构造weight 2-2 构造scorer 2-3 求交集并集差集 .1 测试代码 .1-1 写入代码 public static void writeIndex() throws IOException{ Directory directory = FSDirectory.open(Paths.get("/Users/waixingren/bigdata-java/mysolr52test/lucenecountdata")); Analyzer analyzer = new StandardAnalyzer(); IndexWriterConfig config = new IndexWriterConfig(analyzer); config.setUseCompoundFile(false); IndexWriter indexWriter = new IndexWriter(directory, config); Document doc1 = newDoc("1", "cubeli", "one of tencent employee"); Document doc2 = newDoc("2", "liyong", "one of tencent employee"); Document doc3 = newDoc("3", "yangziying", "one of tencent employee"); Document doc4 = newDoc("4", "litairan", "one of tencent employee"); Document doc5 = newDoc("5", "zhanshan", "one of tencent employee"); Document doc6 = newDoc("6", "