solr - 如何对日期索引执行日期范围查询 - SOLR
问题描述
date
在 SOLR索引字段上运行范围查询的正确方法是什么。schema.xml
以下是字段定义文件的快照:
<dynamicField name="ds_*" type="pdate" indexed="true" stored="false" multiValued="false" docValues="true"/>
上下文:SOLR 文档包含一个日期元素和值,如"ds_clip_date":"2020-10-14T12:00:00Z"
. 要求是允许用户从本月/过去 30 天/过去 90 天/今年获取文档。
我尝试从 SOLR 查询仪表板在下面构建 - 但这给了我所有文档而不考虑范围:
http://localhost:8983/solr/testcore/select?facet.field=ds_clip_date&facet.query=facet.range%3Dds_clip_date%26f.ds_clip_date.facet.range.start%3D2020-11-17&facet=on&fl=ds_clip_date&q=*%3A*&rows=200&start=0
我得到以下摘要:
"facet_counts":{
"facet_queries":{
"facet.range=ds_clip_date&f.ds_clip_date.facet.range.start=2020-11-17":0},
"facet_fields":{
"ds_clip_date":[
"2020-12-15T12:00:00Z",20,
"2020-12-16T12:00:00Z",14,
"2020-09-25T12:00:00Z",1,
"2020-10-14T12:00:00Z",1,
"2020-10-20T12:00:00Z",1,
"2020-10-22T12:00:00Z",1,
"2020-11-24T12:00:00Z",1,
"2020-12-17T12:00:00Z",1]},
"facet_ranges":{},
"facet_intervals":{},
"facet_heatmaps":{}}
此外,参考其他一些 QA,尝试构建如下:
http://localhost:8983/solr/testcore/select?facet=true&facet.field=ds_clip_date&facet.range=ds_clip_date&f.ds_clip_date.facet.range.start=2020-12-15T00:00:00Z&f.ds_clip_date.facet.range.end=NOW&f.ds_clip_date.facet.range.gap=%2B1DAY
结果如下:
{
"response":{"numFound":0,"start":0,"numFoundExact":true,"docs":[]
},
"facet_counts":{
"facet_queries":{},
"facet_fields":{
"ds_clip_date":[]},
"facet_ranges":{
"ds_clip_date":{
"counts":[
"2020-12-15T00:00:00Z",0,
"2020-12-16T00:00:00Z",0,
"2020-12-17T00:00:00Z",0],
"gap":"+1DAY",
"start":"2020-12-15T00:00:00Z",
"end":"2020-12-18T00:00:00Z"}},
"facet_intervals":{},
"facet_heatmaps":{}}}
但是在上面的摘要中,您可以发现 2020-12-15 有 20 个文档被索引。
我正在运行 SOLR 8.7。
解决方案
推荐阅读
- java - 如何将元素添加到列表中
? - slack - 使用 Slack 用户的数据
- java - 春季启动计划任务没有等待完成关闭
- linux - 使用awk解析转换如下日志
- kubernetes - GKE 中的私有集群如何对同一子网中的 GCP 计算实例 (VM) 进行身份验证?
- wordpress - Wordpress 中的联系表格 7 - 如何隐藏电子邮件中的空白字段?
- reactjs - 无法让 npm 运行启动 testcafe 的脚本
- lua - 为什么这段代码意味着所有表共享一个元表
- javascript - jQuery 在单击下一步时显示和隐藏表单
- azure - 将 DataFactory 连接到 Lotus notes DB