Solr光标和分页 [英] Solr cursor marker and pagination

查看:245
本文介绍了Solr光标和分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将Solr用于我的网站作为搜索引擎,并且我试图了解基本分页和使用光标标记的深页面调页之间的区别。



如我所知,如果你使用基本分页并查询页面1001,每页20个结果,这将会发生:




  • Solr会找到first 1000 * 20个匹配结果

  • 显示1001页的后20个结果



问题是当有人点击下一页。 Solr将首先找到1001 * 20的结果,然后将显示所需的结果。



我没有看到大数字深层分页的正确示例。只有小数字,所以我不知道这个。有人可以澄清吗?



以下示例是否正确?

  ... / query?q = id:book *& sort = pubyear_i + desc,id + asc& fl = title_t,pubyear_i& rows = 1& cursorMark = * 
/ pre>

这给了我nextCursorMark:AoJcfCVib29rMg ==



nextCursorMark我可以去找到我想要的页面。
我现在应该手动浏览页面吗?



或者我应该有第一个查询20000行,得到nextCursorMark,然后使用它与另一个查询只有20行?



我发现有一点奇怪,运行一些查询与20000行只是为了获得nextCursorMark。这是正确的方式吗?



例如,如果你有10页,而用户想要从第1页点击第5页。我需要



我看过这个:如何管理分页与Solr?



并且: https://lucidworks.com/blog/2013/12/12/coming-soon-to-solr



试图找到一个工作示例,但无法。

解决方案

cursorMark 告诉Solr应该开始下一个响应。它类似于第一个示例中的 start 参数。当您通过结果分页时,每个响应 cursorMark 显示下一页开始的位置。



只是寻找第1001页的第一个结果是什么,第一版将工作很好。如果你通过结果分页 - 用户可能或可能不会去下一页,关于使用cursorMarks的观点是每个节点(或在单个节点设置中)知道哪个文档是最后一个要显示的文档,因此,对于每个节点,只能从当前位置返回 rows 文件数。如果你做第一个版本,每个节点都必须返回 start + rows 文档。因此,我们不必试图找出哪些文档是20001之后的十个文档,您只需要回答哪个文档是这个排序关键字之后的十个文档。



另外,cursorMarks会更好地处理对结果集的更新,因为您避免对结果集进行任何更改,将已显示的文档推回到您正在显示的下一页。



请参阅完整示例的参考指南和进一步说明。


I want to use Solr for my website as a search engine and I am trying to understand the difference between basic paging and deep paging with cursor marker.

As far as I understand, if you use the basic pagination and query the page 1001 with 20 results per page this will happen:

  • Solr will find the first 1000*20 matching results
  • display the next 20 results for 1001 page

I guess the problem is when someone clicks next page. Solr will find first the 1001*20 results and after that will show the desired results.

I haven't seen a proper example for deep paging with large numbers. Only with small numbers, so I am not sure about this. Can someone clarify it please?

Is the following example correct?

.../query?q=id:book*&sort=pubyear_i+desc,id+asc&fl=title_t,pubyear_i&rows=1&cursorMark=*

This giving me the "nextCursorMark" : "AoJcfCVib29rMg=="

Now that I have the nextCursorMark I can go and find my desired page. Should I now go through the pages manually? Should I create a loop where I search for that particular page I want?

Or should I have the first query with 20000 rows, get the nextCursorMark and then use it with another query having only 20 rows?

I find it a bit strange to run some query with 20000 rows just to get the nextCursorMark. Is it the correct way to do it?

And what if, for example you have 10 pages and the user wants to click on page 5 from page 1. Will I need to go through each page manually to get there?

Edit:

I have read this: How to manage "paging" with Solr?

And this: https://lucidworks.com/blog/2013/12/12/coming-soon-to-solr-efficient-cursor-based-iteration-of-large-result-sets/

Tried to find a working example but couldn't.

解决方案

The cursorMark tells Solr where it should start the next response. It's analogous to the start parameter in your first example. As you're paginating through the results, each response's cursorMark shows where the next page starts.

If you're just looking for "what is the first result on page 1001", first version will work just fine. If you're paginating through the results - were a user may or may not go to the next page, the point about using cursorMarks is that each node (or in a single node setup) know which document was the last one to be shown, and thus, can return only rows number of documents from the current position for each node. If you'd do the first version, each node would have to return start + rows documents. So instead of trying to find out "which documents are the ten ones after 20001", you just need to answer "which documents are the next ten after this sort key".

In addition cursorMarks handles updates to the result set better, as you avoid any changes to the result set that would push documents that have already been shown back into the next page you're displaying.

See the reference guide for complete examples and further descriptions.

这篇关于Solr光标和分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆