# Behaviour of match phrase query on english analyzed fields with stopwords

**URL:** <https://discuss.elastic.co/t/behaviour-of-match-phrase-query-on-english-analyzed-fields-with-stopwords/155210>\
**Category:** Elasticsearch\
**Created:** [November 2, 2018, 4:57pm UTC](https://discuss.elastic.co/t/behaviour-of-match-phrase-query-on-english-analyzed-fields-with-stopwords/155210 "2018-11-02T16:57:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jaspreet\_Singh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jaspreet_singh/32/58296_2.png) [@Jaspreet\_Singh](https://discuss.elastic.co/u/Jaspreet_Singh)\
**Post date:** [November 2, 2018, 4:57pm UTC](https://discuss.elastic.co/t/behaviour-of-match-phrase-query-on-english-analyzed-fields-with-stopwords/155210/1 "2018-11-02T16:57:40Z")

</div>

Hi,

I wanted to confirm a weird behaviour im observing when using match\_phrase query on english analyzed fields with stopwords.

1. Assume my search string is `analytics and prediction`.
2. Assume again, when searching against an English analyzed field, the tokens generated are `analyt` and `predict`.
3. Now, when doing a match\_phrase search against that field, I would expect ONLY the following text phrases to match:
  - `analytics and prediction`
  - `analytics prediction`
  - `analyze and prediction`
  - `analyze prediction`
  - `analysis predict`
  - `analysis and predict`  
etc.  
... since `and` being a stopword, instances where there is nothing between analytics and prediction, should also show up as a match in addition to where there is an `and`. But nothing else.

4. However the behaviour im seeing is different (also backed by `explain = true`. Instead, the tokens match\_phrase uses are `analyse ? predict` where ? is a wild card.
5. So in essence it works like a match\_phrase with a slop, matching ANY phrase that begins with words that stem to `analyze` and end with words that stem to `predict`.

I'm wondering why! It makes it almost impossible to get a strict phrase match whenever there is a stopword in query string.

---

<div class="post-metadata">

**Author:** ![Jaspreet\_Singh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jaspreet_singh/32/58296_2.png) [@Jaspreet\_Singh](https://discuss.elastic.co/u/Jaspreet_Singh)\
**Post date:** [November 5, 2018, 9:29pm UTC](https://discuss.elastic.co/t/behaviour-of-match-phrase-query-on-english-analyzed-fields-with-stopwords/155210/2 "2018-11-05T21:29:01Z")

</div>

Any thoughts anyone?

---

<div class="post-metadata">

**Author:** ![Jaspreet\_Singh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jaspreet_singh/32/58296_2.png) [@Jaspreet\_Singh](https://discuss.elastic.co/u/Jaspreet_Singh)\
**Post date:** [November 7, 2018, 3:52pm UTC](https://discuss.elastic.co/t/behaviour-of-match-phrase-query-on-english-analyzed-fields-with-stopwords/155210/3 "2018-11-07T15:52:10Z")

</div>

@dadoonet would appreciate any pointers

---

<div class="post-metadata">

**Author:** ![Jaspreet\_Singh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jaspreet_singh/32/58296_2.png) [@Jaspreet\_Singh](https://discuss.elastic.co/u/Jaspreet_Singh)\
**Post date:** [November 21, 2018, 6:30pm UTC](https://discuss.elastic.co/t/behaviour-of-match-phrase-query-on-english-analyzed-fields-with-stopwords/155210/4 "2018-11-21T18:30:52Z")

</div>

I figured it out. Really the gist is ...  
For a document to be considered a match for any phrase say, “quick brown fox”, the following must be true:

- `quick` , `brown` , and `fox` must all appear in the field.
- The position of `brown` must be `1` greater than the position of `quick` .
- The position of `fox` must be `2` greater than the position of `quick` .  
Then the specifics are down to the tokens that are generated.

---

<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:** [December 19, 2018, 6:30pm UTC](https://discuss.elastic.co/t/behaviour-of-match-phrase-query-on-english-analyzed-fields-with-stopwords/155210/5 "2018-12-19T18:30:54Z")

</div>

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