Query on Solr, limit the number of rows per day

早过忘川 提交于 2020-01-17 01:37:22

问题


I want to get documents from Solr by querying the same keywords everyday in time interval, with rows limit applied on each day.

For example, if the keywords is "Machine Learning", the time interval is in between 21-11-2018 to 23-11-2018, each day is limited by 100 rows at most. Currently I naively query on each day:

  • q="Machine Learning", fl=date:21-11-2018, rows=100
  • q="Machine Learning", fl=date:22-11-2018, rows=100
  • q="Machine Learning", fl=date:23-11-2018, rows=100

Is there an equivalent way by just a single query to Solr?


回答1:


Yes. You can use group query. Your query will be:

q="Machine Learning", group=true, group.query=date:21-11-2018, group.query=date:22-11-2018, group.query=date:23-11-2018, group.limit=100

This can be also accomplished using the following query:

q="Machine Learning", group=true, group.field=date, fq=date:21-11-2018 OR date:22-11-2018 OR date:23-11-2018, group.limit=100

You can also use pagination and sorting on group results if needed.

Resource : https://lucene.apache.org/solr/guide/7_5/result-grouping.html



来源:https://stackoverflow.com/questions/53552163/query-on-solr-limit-the-number-of-rows-per-day

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!