# Need help with ES Query

**URL:** <https://discuss.elastic.co/t/need-help-with-es-query/15550>\
**Category:** Elasticsearch\
**Created:** [February 2, 2014, 6:09pm UTC](https://discuss.elastic.co/t/need-help-with-es-query/15550 "2014-02-02T18:09:31Z")\
**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 2, 2014, 6:09pm UTC](https://discuss.elastic.co/t/need-help-with-es-query/15550/1 "2014-02-02T18:09:31Z")

</div>

Hi,

I'm using an analyzer which includes a standard tokenizer and  
lowercase,asciifolding,suggestions\_shingle and edgengrams as token filters  
in it. The analyzer is same for both indexing and searching. So, for a text  
like delhi to goa will be analyzed like:

{  
"tokens" : [ {  
"token" : "de",  
"start\_offset" : 0,  
"end\_offset" : 5,  
"type" : "word",  
"position" : 1  
}, {  
"token" : "del",  
"start\_offset" : 0,  
"end\_offset" : 5,  
"type" : "word",  
"position" : 1  
}, {  
"token" : "delh",  
"start\_offset" : 0,  
"end\_offset" : 5,  
"type" : "word",  
"position" : 1  
}, {  
"token" : "delhi",  
"start\_offset" : 0,  
"end\_offset" : 5,  
"type" : "word",  
"position" : 1  
}, {  
"token" : "de",  
"start\_offset" : 0,  
"end\_offset" : 8,  
"type" : "word",  
"position" : 1  
}, {  
"token" : "del",  
"start\_offset" : 0,  
"end\_offset" : 8,  
"type" : "word",  
"position" : 1  
}, {  
"token" : "delh",  
"start\_offset" : 0,  
"end\_offset" : 8,  
"type" : "word",  
"position" : 1  
}, {  
"token" : "delhi",  
"start\_offset" : 0,  
"end\_offset" : 8,  
"type" : "word",  
"position" : 1  
}, {  
"token" : "delhi ",  
"start\_offset" : 0,  
"end\_offset" : 8,  
"type" : "word",  
"position" : 1  
}, {  
"token" : "delhi t",  
"start\_offset" : 0,  
"end\_offset" : 8,  
"type" : "word",  
"position" : 1  
}, {  
"token" : "delhi to",  
"start\_offset" : 0,  
"end\_offset" : 8,  
"type" : "word",  
"position" : 1  
}, {  
"token" : "de",  
"start\_offset" : 0,  
"end\_offset" : 12,  
"type" : "word",  
"position" : 1  
}, {  
"token" : "del",  
"start\_offset" : 0,  
"end\_offset" : 12,  
"type" : "word",  
"position" : 1  
}, {  
"token" : "delh",  
"start\_offset" : 0,  
"end\_offset" : 12,  
"type" : "word",  
"position" : 1  
}, {  
"token" : "delhi",  
"start\_offset" : 0,  
"end\_offset" : 12,  
"type" : "word",  
"position" : 1  
}, {  
"token" : "delhi ",  
"start\_offset" : 0,  
"end\_offset" : 12,  
"type" : "word",  
"position" : 1  
}, {  
"token" : "delhi t",  
"start\_offset" : 0,  
"end\_offset" : 12,  
"type" : "word",  
"position" : 1  
}, {  
"token" : "delhi to",  
"start\_offset" : 0,  
"end\_offset" : 12,  
"type" : "word",  
"position" : 1  
}, {  
"token" : "delhi to ",  
"start\_offset" : 0,  
"end\_offset" : 12,  
"type" : "word",  
"position" : 1  
}, {  
"token" : "delhi to g",  
"start\_offset" : 0,  
"end\_offset" : 12,  
"type" : "word",  
"position" : 1  
}, {  
"token" : "delhi to go",  
"start\_offset" : 0,  
"end\_offset" : 12,  
"type" : "word",  
"position" : 1  
}, {  
"token" : "delhi to goa",  
"start\_offset" : 0,  
"end\_offset" : 12,  
"type" : "word",  
"position" : 1  
}, {  
"token" : "to",  
"start\_offset" : 6,  
"end\_offset" : 8,  
"type" : "word",  
"position" : 2  
}, {  
"token" : "to",  
"start\_offset" : 6,  
"end\_offset" : 12,  
"type" : "word",  
"position" : 2  
}, {  
"token" : "to ",  
"start\_offset" : 6,  
"end\_offset" : 12,  
"type" : "word",  
"position" : 2  
}, {  
"token" : "to g",  
"start\_offset" : 6,  
"end\_offset" : 12,  
"type" : "word",  
"position" : 2  
}, {  
"token" : "to go",  
"start\_offset" : 6,  
"end\_offset" : 12,  
"type" : "word",  
"position" : 2  
}, {  
"token" : "to goa",  
"start\_offset" : 6,  
"end\_offset" : 12,  
"type" : "word",  
"position" : 2  
}, {  
"token" : "go",  
"start\_offset" : 9,  
"end\_offset" : 12,  
"type" : "word",  
"position" : 3  
}, {  
"token" : "goa",  
"start\_offset" : 9,  
"end\_offset" : 12,  
"type" : "word",  
"position" : 3  
} ]  
}

Now, the problem which I'm facing is while querying for "delhi t" I'm not getting documents which contains maximum matches for the analyzed tokens of "delhi t" on the top:  
Instead I get docs which contain only "delhi" on the top.

I think ES find docs which have maximum match for a certain analyzed search field which is not happening over here. Can anyone please tell me why is it not working ? IS there any other query type like match or boolean query which I need to use ?

Any help will be appreciated.

Thanks

--  
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/f5e3eabb-a9de-4d20-9a2e-29bed3c6bed4%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f5e3eabb-a9de-4d20-9a2e-29bed3c6bed4%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/need-help-with-es-query/15550/2 "2017-07-06T01:53:23Z")

</div>


