Requirement: Each document in the SOLR index has a time field, which is the time period for knowledge. such as Creatime;
The requirement to compare the current time with the time of the Creatime field in the query, if the current time is greater than creattime this time, the knowledge is outdated knowledge, less than this time period for effective knowledge. We query for effective knowledge.
WORKAROUND: I use the method of function query, using MS function, calculate the difference between creatime and current time now Creatime-now:ms (Creatime,now), and then take the reciprocal: Recip (MS (Creatime,now), 3.16e-11,1,1). of which 3.16e-11 is the representation of the 3.16*e-12. The resulting number range is in the (0,1) interval. Filter the function values using the Functionrangeqparserplugin plugin.
Final filter query: Fq={!frange l=0 U=1.0}recip (MS (Creatime,now), 3.16e-11,1,1).
Create a range query from a function:
Other parameters:
l, lower range, optional)
u, upper range, optional)
incl, including lower bound: True/false, optional, true by default
incu, including upper bound: True/false, optional, true by default
Example: {!frange l=1000 u=50000}myfield
Filter Query Example::fq={!frange l=0 u=2.2}sum(user_ranking,editor_ranking)
This is my solution, if there is a better solution, please point out. Thank you!
Knowledge query for fields that resolve valid time