Lucene网页分页 [英] Lucene web paging
问题描述
我正在使用Lucene
创建一个我需要实现分页的Web应用程序.我在这里看到了有关在收集器上使用偏移量的不同示例.但是,这些似乎已经很老了.我相信Lucene 3.5
(或者3.6不记得是哪个)添加了此内容.我已经看到了IndexSearcher
方法searchAfter
.但是,它要求您将最后一个ScoreDoc
传递给它.因为这是一个Web应用程序,所以我无法将上一个结果(作为ScoreDoc对象)传递给下一个请求.所以,我的问题是这通常是怎么做的?
I am creating a web app with Lucene
that I need to implement paging. I have seen here the different examples about using an offset on the collector. However, those seem to be old. Lucene 3.5
(or 3.6 can't remember which) added this I believe. I have seen the IndexSearcher
method searchAfter
. However, it requires you pass it the last ScoreDoc
. Because this is a web app, I have no way to pass the last result (as a ScoreDoc object) to the next request. So, my question is how is this typically done?
我真正想出的唯一方法是在构建时在索引中添加唯一键.然后,在尝试获取下一页时,将该键作为post参数传递.然后,我将不得不搜索该键以获取文档ID,然后将该文档与searchAfter一起使用.我认为我必须使用自己的唯一密钥,因为我不能依靠文档ID保持不变.我对此是否正确?
The only way that I have really come up with is to add in a unique key into the index when building. Then, pass that key as a post parameter when trying to get the next page. Then, I would have to search for that key to get the document id and pull that document to use with searchAfter. I think I have to use my own unique key because I cannot rely on the document id to stay the same. Am I correct on this?
如果有更好的方法,请告诉我.这是我第一次尝试Lucene.
If there are better ways, please let me know. This is my first attempt at Lucene.
推荐答案
但是,它要求您将最后一个ScoreDoc传递给它.因为这是一个Web应用程序,所以我无法将上一个结果(作为ScoreDoc对象)传递给下一个请求.所以,我的问题是这通常是怎么做的?
However, it requires you pass it the last ScoreDoc. Because this is a web app, I have no way to pass the last result (as a ScoreDoc object) to the next request. So, my question is how is this typically done?
我不明白您的问题,如果您想使用searchAfter,只需编写一个ScoreDoc传递给它即可.您的webapp可以传递整数并且可以浮动吗?
I don't understand your problem, if you want to use searchAfter, just make a ScoreDoc to pass to it. your webapp can pass ints and floats right?
/** Constructs a ScoreDoc. */
public ScoreDoc(int doc, float score) {
这篇关于Lucene网页分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!