FastFoodCoding

Login


Connect with one of the following accounts





Login

Please wait while we redirect...

Views: 203 Ask New Question


Following is the query I am trying on Elasticsearch. Basically, I want to filter by two fields.

GET /users/doc/_search
{
    "size": 20, 
    "query": {
        "term" : {
            "FirstName.keyword": "foo",
            "LastName.keyword": "bar"
        }
    }
}

and i am getting following exception

{
  "error": {
    "root_cause": [
      {
        "type": "parsing_exception",
        "reason": "[term] query doesn't support multiple fields, found [FirstName.keyword] and [FirstName.keyword]",
        "line": 6,
        "col": 39
      }
    ],
    "type": "parsing_exception",
    "reason": "[term] query doesn't support multiple fields, found [LastName.keyword] and [LastName.keyword]",
    "line": 6,
    "col": 39
  },
  "status": 400
}
On By


1 Answer


Change your query to following

GET /users/doc/_search
{
  "query": {
    "bool": {
      "must": [
        {
         "term" : {
            "FirstName.keyword": "foo"
          }
        },
        {
          "term" : {
            "LastName.keyword": "bar"
          }
        }
      ]
    }
  }
}
On By


Answer This Question


Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News