How to filter query in solr by date?

前端 未结 3 637
我在风中等你
我在风中等你 2021-02-02 07:27

In my SOLR there is date field(published_date) and values are in this format \"2012-09-26T10:08:09.123Z\"

How I can search by simple input like \"2012-09-10\" i

3条回答
  •  -上瘾入骨i
    2021-02-02 08:10

    If you want to get last week publications you can do somehting like:

    &fq=published_date:[NOW-7DAY/DAY TO NOW]
    

    But if you want a concrete date you must do it in the SOLR date format:

    &fq=published_date:[2013-07-17T00:00:00Z TO NOW]
    

    Last but not least.

    • use [ ] for inclusive ranges
    • use { } for exclusive ranges
    • you can mix them like [ } for inclusive - exclusive and vice versa { ]

    I hope that helps

提交回复
热议问题