简体   繁体   English

在弹性搜索中过滤?

[英]Filtering in Elastic Search?

I'm using date_histogram api to get the actual count using the interval (hour/day/week or month).我正在使用 date_histogram api 使用间隔(小时/天/周或月)获取实际计数。 Also I have a feature which I'm having trouble implementing, a user can filter the results by entering an startDate and endDate (textbox) which will be queried using a field timestamp.另外我有一个功能,我在实现时遇到了麻烦,用户可以通过输入 startDate 和 endDate(文本框)来过滤结果,这将使用字段时间戳进行查询。 So how can I filter the results by querying only one field (which is TIMESTAMP) while using date_histogram api or any api so I can achieve my desire result.那么如何在使用 date_histogram api 或任何 api 时通过仅查询一个字段(即 TIMESTAMP)来过滤结果,以便我可以实现我想要的结果。

In SQL I will just use a between operator to get the result but from what I've read so far their is no BETWEEN operator in Elastic Search (not sure).在 SQL 中,我将只使用 between 运算符来获取结果,但从我目前阅读的内容来看,它们在 Elastic Search 中没有 BETWEEN 运算符(不确定)。

I have this script so far:到目前为止,我有这个脚本:

curl 'http://anotherdomain.com:9200/myindex/_search?pretty=true' -d '{
               "query" : { 
                  "filtered" : { 
                     "filter" : { 
                        "exists" : { 
                           "field" : "adid" 
                        } 
                     }, 
                     "query" : { 
                        "query_string" : {
                          "fields" : [
                            "adid", "imp"
                            ],
                            "query" : "525826 AND true"
                        }
                     }

                  } 
               },
               "facets" : {
                  "histo1":{
                    "date_histogram":{
                      "field":"timestamp",
                      "interval":"day"
                    }
                  }
                } 
            }'

在 elasticsearch 中,您可以使用过滤器的范围查询来实现这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM