加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

lucene in action_index and search

发布时间:2020-12-14 06:29:51 所属栏目:Java 来源:网络整理
导读:在这里给大家来一些关于lucene in action的一些东东 你可以到:?了解更新,更全的关于lucene的信息。 下面我做的demo,分享给大家: : [两个参数之间有空格] args[0] = "C:UsershongjieDesktophongten_temphongten_index"; args[1] = "C:Usershongjie

在这里给大家来一些关于lucene in action的一些东东

你可以到:?了解更新,更全的关于lucene的信息。

下面我做的demo,分享给大家:

[两个参数之间有空格]

args[0] = "C:UsershongjieDesktophongten_temphongten_index";

args[1] = "C:UsershongjieDesktophongten_templucene-3.5.0";

main(String[] args) (args.length != 2 IllegalArgumentException("Usage: java " + Indexer..getName() + " " String indexDir = args[0 String dataDir = args[1 start = Indexer index = numIndexed = index.index(dataDir, } end = System.out.println("indexing " + numIndexed + " files took " + (end - start) + " millseconds!" @SuppressWarnings("deprecation" Indexer(String indexDir) Directory dir = FSDirectory.open( writer = IndexWriter(dir, StandardAnalyzer(Version.LUCENE_35), close() index(String dataDir,FileFilter filter) File[] files = (!f.isDirectory() && !f.isHidden() && f.exists() && f.canRead() && (filter == || indexFile(File f) System.out.println("Indexing " + Document doc = Document getDocument(File f) Document doc = doc.add( Field("contents", doc.add( Field("filename" doc.add( Field("fullpath" TextFilesFilter pathname.getName().toLowerCase().endsWith(".txt" }

main(String[] args) (args.length != 2 IllegalArgumentException("Usage: java " + Indexer..getName() + " " String indexDir = args[0 String q = args[1 search(String indexDir,String q) Directory dir = FSDirectory.open( IndexSearcher is = QueryParser parser = QueryParser(Version.LUCENE_35,"contents", Query query = start = TopDocs hits = is.search(query,10 end = System.out.println("Found "+hits.totalHits + " document(s) (in " + (end - start) +" millsecondes) that matched query '"+ q+"':" Document doc = System.out.println(doc.get("fullpath" }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读