针对给定时间范围和使用 AND 运算符的深度 Elasticsearch 通配符查询

Deep Elasticsearch wildcard query for given time range and with AND operator

我设法构建了

的查询

现在我想扩展查询以支持部分匹配,但我很难做到这一点。如有任何建议,我们将不胜感激。

映射

"event": {
    "properties": {
        "alarmId": {
            "type": "string",
            "index": "not_analyzed"
        },
        "startTimestamp": {
            "type": "long"
        },
        ...
    }
}

当前查询

{
    "bool": {
        "must":[
            {"range": {"endTimestamp": {"gte": ?0}}},
            {"range": {"startTimestamp": {"lte": ?1}}}
        ],
        "should": [
            {"match": {"_all": {"query": "?2", "zero_terms_query": "all", "operator": "and"}}}
        ],
        "minimum_should_match" : 1
    }
}

回答(感谢Val

{
    "bool": {
        "must":[
            {"range": {"endTimestamp": {"gte": ?0}}},
            {"range": {"startTimestamp": {"lte": ?1}}}
        ],
        "should": [
            {"query_string": {"query": "?2"}}"
        ],
        "minimum_should_match" : 1
    }
}

现在查询支持grouping, wildcards and more.