Lucene大大简化了在应用中集成全文搜索的功能。但实际上Lucene十分简单,我可以在五分钟之内向你展示如何使用Lucene。1. 建立索引为了简单起见,我们下面为一些字符串创建内存索引:StandardAnalyzer analyzer = new StandardAnalyzer(Version.LUCENE_40);
Directory index = new RAMDirectory();
IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_40, analyzer);
IndexWriter w = new IndexWriter(index, config);
addDoc(w, "Lucene in Action", "193398817");
addDoc(w, "Lucene for Dummies", "55320055Z");
addDoc(w, "Managing Gigabytes", "55063554A");
addDoc(w, "The Art of Computer Science", "9900333X");
w.close();addDoc()方法把文档(译者注:这里的文档是Lucene中的Document类的实例)添加到索引中。private static
...
继续阅读
(31)