# Query using Shingle filter on 5.1.2 and 5.2.2 behave differently

**URL:** <https://discuss.elastic.co/t/query-using-shingle-filter-on-5-1-2-and-5-2-2-behave-differently/193007>\
**Category:** Elasticsearch\
**Created:** [July 31, 2019, 12:11am UTC](https://discuss.elastic.co/t/query-using-shingle-filter-on-5-1-2-and-5-2-2-behave-differently/193007 "2019-07-31T00:11:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mingchi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mingchi/32/51289_2.png) [@mingchi](https://discuss.elastic.co/u/mingchi)\
**Post date:** [July 31, 2019, 12:11am UTC](https://discuss.elastic.co/t/query-using-shingle-filter-on-5-1-2-and-5-2-2-behave-differently/193007/1 "2019-07-31T00:11:26Z")

</div>

I have a shingle filter:

```auto
"custom_shingle_filter": {
    "type": "shingle",
    "max_shingle_size": 2,
    "min_shingle_size": 2,
    "token_separator": "",
    "output_unigrams": true
}   

```

Then I use this shingle filter in my search analyzer:

```auto
"custom_search_analyzer": {
    "type": "custom",
    "tokenizer": "whitespace",
    "filter": [
        "custom_shingle_filter"
    ]
}

```

When I run `validate` API to my query:

```auto
GET /test_index/test_type/_validate/query?explain=true
{
  "query" : {
    "match" : {
      "test_field" : {
        "query" : "macbook pro",
        "operator" : "and",
        "analyzer" : "custom_shingle_filter"
      }
    }
  }
}

```

In 5.2.2, I got:  
`+Graph(+test_field:macbook +test_field:pro, test_field:macbookpro, hasBoolean=true, hasPhrase=false)`  
It means it will query (`macbook` and `pro`) or `macbookpro`  
But in 5.1.2:  
`+Synonym(test_field:macbook test_field:macbookpro) +test_field:pro`  
It means it will query (`macbook` or `macbookpro`) and `pro` ?????

The result in 5.2.2 makes sense to me, but I got different behaviour on 5.1.2 and (unfortunately) it's what we have on production.  
Any idea?  
Thanks.

---

<div class="post-metadata">

**Author:** ![cbuescher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cbuescher/32/60402_2.png) [@cbuescher](https://discuss.elastic.co/u/cbuescher)\
**Post date:** [July 31, 2019, 10:13am UTC](https://discuss.elastic.co/t/query-using-shingle-filter-on-5-1-2-and-5-2-2-behave-differently/193007/2 "2019-07-31T10:13:30Z")

</div>

This is very likely due to [https://github.com/elastic/elasticsearch/pull/21517](https://github.com/elastic/elasticsearch/pull/21517)

---

<div class="post-metadata">

**Author:** ![mingchi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mingchi/32/51289_2.png) [@mingchi](https://discuss.elastic.co/u/mingchi)\
**Post date:** [August 6, 2019, 9:30pm UTC](https://discuss.elastic.co/t/query-using-shingle-filter-on-5-1-2-and-5-2-2-behave-differently/193007/3 "2019-08-06T21:30:20Z")

</div>

Thanks, that's helpful!

---

<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:** [September 3, 2019, 9:30pm UTC](https://discuss.elastic.co/t/query-using-shingle-filter-on-5-1-2-and-5-2-2-behave-differently/193007/4 "2019-09-03T21:30:29Z")

</div>

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