0
votes

I use ElasticSearch 7.0, and I have this simple query :

"bool": {
    "must": {
        "match": {
            "title": {
                "query": "engineer"
            }
        }
    },
    "filter": {
        "0": {
            "term": {
                "type_id": 1
            }
        },
        "term": {
            "active": 1
        }
    }
}

And I get this error :

[match] malformed query, expected [END_OBJECT] but found [FIELD_NAME]

I tried :

"must": {
    "match": {
        "title": "engineer"
    }
},

But same error, I can't see my syntax mistake here ? I have same query working with multimatch with same filters.

1

1 Answers

1
votes

Your filters must be enclosed in an array, like this:

{
  "bool": {
    "must": {
      "match": {
        "title": {
          "query": "engineer"
        }
      }
    },
    "filter": [
      {
        "term": {
          "type_id": 1
        }
      },
      {
        "term": {
          "active": 1
        }
      }
    ]
  }
}