0

我想将以下 sql 查询提取到 elasticsearch。

Select * 
from someTable
Where @timestamp < some_date and @timestamp >= some_other_date
and dst != '-'

然后对返回的文档进行一些聚合。我已经弄清楚了聚合部分,并且效果很好。但是我没有正确过滤文档。我尝试了以下查询,但我得到了带有 dst = '-' 的文档,这些文档依次在聚合中计算。

查询

"query": {                              
    "bool": {
        "must_not": {
            "term": {
                "dst": '-'
            }
        }, 
        "filter":{
            "range":{
                "@timestamp":{
                    "gte":"a date",
                    "lt": "another date"
                }
            }
        }
    }   
}      

难道我做错了什么。我将大小设置为 0,因为我正在使用聚合(此处未显示)。Elasticsearch ver2.4 和 python elasticsearch 库。

我知道它不起作用,因为聚合结果包含 dst 为“-”的文档中的值

4

1 回答 1

1

不应分析此字段,因为它分析器从索引中的字段中删除 - char。

如果出于其他原因需要分析此字段,请使用多字段。 https://www.elastic.co/guide/en/elasticsearch/reference/current/multi-fields.html

于 2016-10-05T10:18:11.573 回答