Warning A wild sentence not based on previous experience or known facts. :)
- Run the query without sorting and rows = 0 to get the number of matches. Disable faceting, etc. To increase productivity, we only need the total number of matches.
- Depending on the number of matches from step # 1, the distribution of your data and the number / offset of the desired results, run another query that sorts by date and also adds a filter to the date, for example
fq=date:[NOW()-xDAY TO *] where x is the approximate period of time in days during which we will find the required number of relevant documents. - If the number of results from step # 2 is less than necessary, slightly loosen the filter and run another query.
First, you can use the following to evaluate x :
If you uniformly add n documents per day to the index of documents of size n and the specific query matched by d documents in step # 1, then to get top r results, you can use x = (N*r*1.2)/(d*n) . If you need to put off the filter too often in step 3, then slowly increase the value of 1.2 in the formula as necessary.
source share