当前位置: 代码迷 >> Java Web开发 >> lucene 搜索速度有关问题
  详细解决方案

lucene 搜索速度有关问题

热度:24   发布时间:2016-04-17 10:27:55.0
lucene 搜索速度问题
刚刚接触lucene,自己按着教程开始建立索引(一共50个索引文件,22MB)
然后用下面的搜索,消耗时间一般在1s左右,是不是有点太慢了,还是我那里写的有问题?

电脑配置:i3 ,2GB RAM,win7

ps:lucene 发音是“卢森”还是“卢森斯”? 

Java code
public void testSearch() throws IOException, ParseException {        // 读取indexer文件        IndexReader reader = IndexReader.open(FSDirectory.open(new File(TestIndexer.indexPath)));        IndexSearcher sercher = new IndexSearcher(reader);                Long sDate = System.currentTimeMillis();                QueryParser parser = new QueryParser(Version.LUCENE_35,"正文",new IKAnalyzer());        Query query = parser.parse("活动");                TopDocs topDoc =  sercher.search(query,5);                System.out.println(topDoc.totalHits);                ScoreDoc[] hits = topDoc.scoreDocs;        for(ScoreDoc sd:hits){            Document doc = sercher.doc(sd.doc);            System.out.println("作者 = "+doc.get("作者"));            System.out.println("标题 = "+doc.get("标题"));            System.out.println("日期 = "+doc.get("日期"));            System.out.println("路径 = "+doc.get("路径"));            System.out.println("................");        }                Long sDate2 = System.currentTimeMillis();                System.out.println("消耗时间:"+(sDate2-sDate)+"毫秒");                sercher.close();        reader.close();    }


------解决方案--------------------
顶顶顶!lz,先到网上搜搜!
  相关解决方案