内容简介:翻译自:https://stackoverflow.com/questions/4186500/compass-lucene-hits
我使用Lucene和Compass,我遇到了一个问题:
try {
CompassHits hits = compassQuery.hits();
for (CompassHit compassHit : hits) {
if (results.size() >= maxResults) {
Log.info(this, "Number of results exceeded %,d for query %s", maxResults, query);
break;
} else {
results.add((T) compassHit.getData());
}
}
}
当数据由compassHit.getData()创建时;并且它重新执行搜索是100次命中,是否有可能将其更改为200或更多?
编辑:
来自wiki apache org:
“迭代所有命中的速度很慢有两个原因.首先,当你需要超过100次点击时,返回Hits对象的search()方法会在内部重新执行搜索”.
我的问题是有机会将这个值“100”改为“200”吗?
但重要的是我使用罗盘或原始的Lucene.
我在2.9.2中查看了Hits的来源.这是硬编码.它看起来像是硬编码的
Hits(Searcher s, Query q, Filter f) throws IOException {
this.weight = q.weight(s);
this.searcher = s;
this.filter = f;
this.nDeletions = countDeletions(s);
getMoreDocs(50);
this.lengthAtStart = this.length;
}
如果您没有使用Compass,则可以按照JavaDoc for Hits中的说明进行操作,建议更换
相反,e. G.可以使用TopDocCollector和TopDocs:
TopDocCollector collector = new TopDocCollector(hitsPerPage);
searcher.search(query, collector);
ScoreDoc[] hits = collector.topDocs().scoreDocs;
for (int i = 0; i < hits.length; i++) {
int docId = hits[i].doc;
Document d = searcher.doc(docId);
// do something with current hit
...
但既然你是,除非你愿意改写指南针的一部分,我认为你被困住了
翻译自:https://stackoverflow.com/questions/4186500/compass-lucene-hits
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Algorithms Unlocked
Thomas H. Cormen / The MIT Press / 2013-3-1 / USD 25.00
Have you ever wondered how your GPS can find the fastest way to your destination, selecting one route from seemingly countless possibilities in mere seconds? How your credit card account number is pro......一起来看看 《Algorithms Unlocked》 这本书的介绍吧!