Multi_match query with filters


(Juan Diego Calle) #1

I want to do a multi_match query with filters and the only way I was able to do it was like this

{
  "query": {
    "bool": {
      "should": [
        {
          "multi_match": {
            "query": "auto bonito rojo en Guanajuato",
            "fields": [
              "attributes.description.value^9",
              "attributes.color.value^14",
              "attributes.province.value^6"
            ]
          }
        }
      ],
      "must": {
        "range": {
          "attributes.price.value": {
            "lte": 10000
          }
        }
      }
    }
  }
}

So the above works, but if I would like to have a "multi_match" and for example "range" under the same must I have problems , I tried this

{
  "query": {
    "bool": {
      "must": [
        {
          "multi_match": {
            "query": "auto bonito rojo en Guanajuato",
            "fields": [
              "attributes.description.value^9",
              "attributes.color.value^14",
              "attributes.province.value^6"
            ]
          },
          "range": {
            "attributes.price.value": {
              "lte": 10000
            }
          }
        }
      ]
    }
  }
}

I get this error "type": "query_parsing_exception" with "reason": "No query registered for [attributes.price.value]".

If I have a "multi_match" under "must", "filter", "must_not", "should", can I have other types like "terms", "range", "match" in the same "must", "filter",etc.

I tried adding filters to this type of multi_match

{
  "query": {
    "multi_match": {
      "query": "auto bonito rojo en Distrito Federal",
      "fields": [
        "attributes.description.value^49.1",
        "attributes.color.value^442.9",
        "attributes.province.value^12997980.9"
      ]
    }
  }
}

But i got errors.

Which is the best way to do this?


(system) #2