# Exception when there are duplicate words in search query

**URL:** <https://discuss.elastic.co/t/exception-when-there-are-duplicate-words-in-search-query/119791>\
**Category:** Elasticsearch\
**Created:** [February 14, 2018, 12:26pm UTC](https://discuss.elastic.co/t/exception-when-there-are-duplicate-words-in-search-query/119791 "2018-02-14T12:26:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sachini\_Perera](https://avatars.discourse-cdn.com/v4/letter/s/ee59a6/32.png) [@Sachini\_Perera](https://discuss.elastic.co/u/Sachini_Perera)\
**Post date:** [February 14, 2018, 12:26pm UTC](https://discuss.elastic.co/t/exception-when-there-are-duplicate-words-in-search-query/119791/1 "2018-02-14T12:26:30Z")

</div>

> ` {"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 ✅  
["test", "blah", "test test"] don't ❎  
Any idea what is wrong with the code here?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 14, 2018, 1:12pm UTC](https://discuss.elastic.co/t/exception-when-there-are-duplicate-words-in-search-query/119791/2 "2018-02-14T13:12:40Z")

</div>

Here is what I tried:

```auto
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:

```auto
{
  "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"
        }
      }
    ]
  }
}

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 14, 2018, 1:13pm UTC](https://discuss.elastic.co/t/exception-when-there-are-duplicate-words-in-search-query/119791/3 "2018-03-14T13:13:01Z")

</div>

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