有关lucene 索引pdf格式文档的问题

来源:互联网 发布:java编程艺术 编辑:程序博客网 时间:2024/06/05 07:57
环境: lucene2.0+pdf.0.7.3+je-analysis-1.4.0.jar+eclipse3.2
//索引文档LuceneInActionCH.pdf
File indexDir = new File("C://index"); // 索引文件存放路径
File dataDir = new File("C://file"); // 文件所存路径

Analyzer analyzer = new MMAnalyzer();
IndexWriter writer = new IndexWriter(indexDir, analyzer, true);

Document doc = LucenePDFDocument.getDocument(new File("C://file//LuceneInActionCH.pdf"));

writer.close();
索引是成功生成,索引文件_1.cfs大小18k.
//查询
QueryParser queryParser = null;
Query query = null;
IndexSearcher indexSearcher = null;
Hits hits = null;
String queryStr = null;



queryParser = new QueryParser("contents", new MMAnalyzer());
queryStr = "使用";
query = queryParser.parse(queryStr);
indexSearcher = new IndexSearcher("c://index");
hits = indexSearcher.search(query);

但查询不到结果,hits.length=0
请问高人,这可能是什么原因造成的?紧急,谢谢!
原创粉丝点击