# Which query type gives me docs which contains maximum number of user typed terms?

**URL:** <https://discuss.elastic.co/t/which-query-type-gives-me-docs-which-contains-maximum-number-of-user-typed-terms/15545>\
**Category:** Elasticsearch\
**Created:** [February 1, 2014, 8:07pm UTC](https://discuss.elastic.co/t/which-query-type-gives-me-docs-which-contains-maximum-number-of-user-typed-terms/15545 "2014-02-01T20:07:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dark\_shadow](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dark\_shadow](https://discuss.elastic.co/u/dark_shadow)\
**Post date:** [February 1, 2014, 8:07pm UTC](https://discuss.elastic.co/t/which-query-type-gives-me-docs-which-contains-maximum-number-of-user-typed-terms/15545/1 "2014-02-01T20:07:51Z")

</div>

Hi,

I want to use a query type which gives me docs with maximum number of  
matching terms with user typed terms. I'm using standard tokenizer along  
with lowercase,asciifolding,suggestions\_shingle and edgengrams token  
filters for both index and search analyzer. Right now I'm using custom  
score query but it is not giving me terms which contains exact/maximum  
number of user typed terms. for eg,

If I search for "delhi t", it gives me:

delhi  
delhi 6  
delhi to new york -----\> after analysis this contains more matching terms  
delhi 7  
delhi to hyderabad ----\> same case here

But in my docs collections, I have many delhi to docs, so  
ideally it should give me those docs which contains "delhi t" as one of the  
terms since there is exact match.

Is there any way by which I can change my custom score query to achieve  
this ?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/b3a86ef5-a8a5-4d29-93e9-a202cd20ee76%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b3a86ef5-a8a5-4d29-93e9-a202cd20ee76%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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 6, 2017, 1:53am UTC](https://discuss.elastic.co/t/which-query-type-gives-me-docs-which-contains-maximum-number-of-user-typed-terms/15545/2 "2017-07-06T01:53:26Z")

</div>


