问题
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