0

I managed to build query that

  • matches all exact values in given time range
  • supports and operator.

Now I want to extend the query to support partial matching but I struggle to do that. Any advice would be appreciated.

Mapping

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

Current query

{
    "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
    }
}
rebeliagamer
  • 1,257
  • 17
  • 33

1 Answers1

0

Answer (thanks to Val)

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

Now query supports grouping, wildcards and more.

Community
  • 1
  • 1
rebeliagamer
  • 1,257
  • 17
  • 33