Exception when there are duplicate words in search query

{"error":{"root_cause":[{"type":"parsing_exception","reason":"[terms] query does not support [0] within lookup element","line":1,"col":150}],"type":"parsing_exception","reason":"[terms] query does not support [0] within lookup element","line":1,"col":150},"status":400}

// my search query would look like

{
  "query": { 
      "terms": {
  		 "blah_blah_field" : ['test test']
  	  }
   }
}

//and my field is as follows

'blah_blah_field' => [
      'type' => 'keyword',
],

When I try to pass the data as array of values and if any value contains duplicate words it throws this error.
If I just search for a word like "test blah" it works.
So simply
["test", "blah", "test blah"] works :white_check_mark:
["test", "blah", "test test"] don't :negative_squared_cross_mark:
Any idea what is wrong with the code here?

Here is what I tried:

DELETE test 
PUT test
{
  "mappings": {
    "doc": {
      "properties": {
        "foo": {
          "type": "keyword"
        }
      }
    }
  }
}
PUT test/doc/1
{
  "foo": "bar bar"
}
GET test/_search
{
  "query": {
    "terms": {
      "foo": [
        "bar bar",
        "bar"
      ]
    }
  }
}

I'm getting:

{
  "took": 16,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": 1,
    "max_score": 1,
    "hits": [
      {
        "_index": "test",
        "_type": "doc",
        "_id": "1",
        "_score": 1,
        "_source": {
          "foo": "bar bar"
        }
      }
    ]
  }
}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.