# NGram Partial Match & limiting nGram results in multiple field query

**URL:** <https://discuss.elastic.co/t/ngram-partial-match-limiting-ngram-results-in-multiple-field-query/62526>\
**Category:** Elasticsearch\
**Created:** [October 7, 2016, 7:03pm UTC](https://discuss.elastic.co/t/ngram-partial-match-limiting-ngram-results-in-multiple-field-query/62526 "2016-10-07T19:03:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jordancardwell](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jordancardwell/32/12347_2.png) [@jordancardwell](https://discuss.elastic.co/u/jordancardwell)\
**Post date:** [October 7, 2016, 7:03pm UTC](https://discuss.elastic.co/t/ngram-partial-match-limiting-ngram-results-in-multiple-field-query/62526/1 "2016-10-07T19:03:22Z")

</div>

Problem: I've implemented a partial search on a name field by indexing the tokenized name (`name` field) as well as a trigram analyzed name (`ngram` field).

I've boosted the `name` field to have exact token matches bubble up to the top of the results.

_all code references in GISTs since pre-formatted text doesn't display well_

[**GIST: Index settings and mapping**](https://gist.github.com/jordancardwell/4fbc488a1d89c6ef40664d31095c0094)

I am trying to implement a query that limits the nGram matches to ones that only match some threshold (say 80%) of the query string. I understand that `minimum_must_match` seems to be what I am looking for, but my problem is forming the query to actually produce those results.

[**GIST: Query Attempts**](https://gist.github.com/jordancardwell/2e690013666e7e1da6ef1acee314b4e6)

I tried a multi-match query, which gives me correct search results, but I haven't had luck omitting results for names that only match a single trigram (say " **odo**" trigram inside "_the **odo** philus_")

I've tried playing around in sense, to manually produce the match queries that this produces to allow me to only apply `minimum_must_match` to the `ngram` field but can't seem to get the syntax right.

Can anyone see what I'm doing wrong?

It seems like this should be fairly straightforward to accomplish, but I must be missing something obvious.

---

<div class="post-metadata">

**Author:** ![jordancardwell](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jordancardwell/32/12347_2.png) [@jordancardwell](https://discuss.elastic.co/u/jordancardwell)\
**Post date:** [November 14, 2016, 8:06pm UTC](https://discuss.elastic.co/t/ngram-partial-match-limiting-ngram-results-in-multiple-field-query/62526/2 "2016-11-14T20:06:58Z")

</div>

Just poking this.. I'm still unable to get this working as expected 😭

---

<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:** [July 5, 2017, 10:05pm UTC](https://discuss.elastic.co/t/ngram-partial-match-limiting-ngram-results-in-multiple-field-query/62526/3 "2017-07-05T22:05:49Z")

</div>


