【问题标题】:Filtering in Elastic Search?在弹性搜索中过滤?
【发布时间】:2012-11-07 05:45:04
【问题描述】:

我正在使用 date_histogram api 使用间隔(小时/天/周或月)获取实际计数。此外,我还有一个在实现时遇到问题的功能,用户可以通过输入将使用字段时间戳查询的 startDate 和 endDate (文本框)来过滤结果。那么如何在使用 date_histogram api 或任何 api 时仅查询一个字段(即 TIMESTAMP)来过滤结果,以便实现我想要的结果。

在 SQL 中,我将只使用 between 运算符来获取结果,但从我目前阅读的内容来看,它们在 Elastic Search 中没有 BETWEEN 运算符(不确定)。

到目前为止我有这个脚本:

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"
                    }
                  }
                } 
            }'

【问题讨论】:

    标签: php elasticsearch


    【解决方案1】:

    在elasticsearch中,您可以使用range过滤器查询来实现。

    【讨论】:

    • 举个例子就好了
    猜你喜欢
    • 1970-01-01
    • 2015-11-20
    • 1970-01-01
    • 1970-01-01
    • 2015-01-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-25
    相关资源
    最近更新 更多