Knowledge query for fields that resolve valid time

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.