# Need help with match query

**URL:** <https://discuss.elastic.co/t/need-help-with-match-query/76631>\
**Category:** Elasticsearch\
**Created:** [February 27, 2017, 2:03pm UTC](https://discuss.elastic.co/t/need-help-with-match-query/76631 "2017-02-27T14:03:51Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Emrah](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/emrah/32/17657_2.png) [@Emrah](https://discuss.elastic.co/u/Emrah)\
**Post date:** [February 27, 2017, 2:03pm UTC](https://discuss.elastic.co/t/need-help-with-match-query/76631/1 "2017-02-27T14:03:51Z")

</div>

Hi,

I need to match an analyzed string in Elasticsearch but couldnt find a way to do it.  
The case is ;

```
Doc 1 Doc 2 QueryString
----------- ---------- -----------------
a a a
b b b
c c c
d e d
                                     g

```

How can i get Doc 1 with Match Query in this case ? Or any other suggestion please. Thank you

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [February 27, 2017, 3:05pm UTC](https://discuss.elastic.co/t/need-help-with-match-query/76631/2 "2017-02-27T15:05:04Z")

</div>

Hey,

you might want to take a look at the match query in combination with `minimum_should_match` - make sure you take some time to read it though.

See  
[https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-match-query.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-match-query.html)  
[https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-minimum-should-match.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-minimum-should-match.html)

--Alex

---

<div class="post-metadata">

**Author:** ![Emrah](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/emrah/32/17657_2.png) [@Emrah](https://discuss.elastic.co/u/Emrah)\
**Post date:** [February 27, 2017, 3:27pm UTC](https://discuss.elastic.co/t/need-help-with-match-query/76631/3 "2017-02-27T15:27:58Z")

</div>

Hey Alex,

Actually i red minimum\_should\_match and i red again when you said 🙂 But in this case, think that a,b,c,d,e & g is dynamic. So i cant decide which one is required. Am i missing something ? Or should i try something else?

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [February 27, 2017, 4:23pm UTC](https://discuss.elastic.co/t/need-help-with-match-query/76631/4 "2017-02-27T16:23:59Z")

</div>

Hey,

you have not mentioned at all what you tried.. in the above case setting minimum should match to `80%` should work.

--Alex

---

<div class="post-metadata">

**Author:** ![Emrah](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/emrah/32/17657_2.png) [@Emrah](https://discuss.elastic.co/u/Emrah)\
**Post date:** [February 27, 2017, 4:50pm UTC](https://discuss.elastic.co/t/need-help-with-match-query/76631/5 "2017-02-27T16:50:54Z")

</div>

Hey,

Sorry bothering you but the last thing that i didnt mention is Querystring can have more than 5 and docs also can have variables in different numbers. So i think 80% minimum should match wouldnt work

---

<div class="post-metadata">

**Author:** ![Emrah](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/emrah/32/17657_2.png) [@Emrah](https://discuss.elastic.co/u/Emrah)\
**Post date:** [February 28, 2017, 1:25pm UTC](https://discuss.elastic.co/t/need-help-with-match-query/76631/6 "2017-02-28T13:25:08Z")

</div>

I am doing something wrong this is what i need to solve,

Doc 1 and Doc 2 have different numbers of variables, when i query on them with Match query the only thing i want to get that matches the ` **most** ` with QueryString.

```
Doc 1 Doc 2 QueryString
----------- ---------- -----------------
a a a
b b b
c c c
d e d
r v g
                 z e
                ... f
                                    ...
```

---

<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 28, 2017, 1:25pm UTC](https://discuss.elastic.co/t/need-help-with-match-query/76631/7 "2017-03-28T13:25:31Z")

</div>

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