# Search Order of term in query

**URL:** <https://discuss.elastic.co/t/search-order-of-term-in-query/7263>\
**Category:** Elasticsearch\
**Created:** [April 8, 2012, 11:08am UTC](https://discuss.elastic.co/t/search-order-of-term-in-query/7263 "2012-04-08T11:08:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kartavya](https://avatars.discourse-cdn.com/v4/letter/k/65b543/32.png) [@Kartavya](https://discuss.elastic.co/u/Kartavya)\
**Post date:** [April 8, 2012, 11:08am UTC](https://discuss.elastic.co/t/search-order-of-term-in-query/7263/1 "2012-04-08T11:08:21Z")

</div>

Hi All,

if I search for "UK Equity", there is a specific order to the phrase.

Your result will have to return like "XXXXXX UK XXXXX Equity" but not  
"XXXXX Equity XXXX UK"

How I can implement this in elastic search?

Please suggest.

Thanks,  
Pulkit Agrawal

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [April 8, 2012, 6:30pm UTC](https://discuss.elastic.co/t/search-order-of-term-in-query/7263/2 "2012-04-08T18:30:45Z")

</div>

you can use text query with text phrase type, possibly using a higher than  
0 slop value (  
[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/text-query.html)),  
which means how far terms within the phrase can be "apart".

On Sun, Apr 8, 2012 at 2:08 PM, Pulkit Agrawal [pulkitdotcom@gmail.com](mailto:pulkitdotcom@gmail.com)wrote:

> Hi All,
> 
> if I search for "UK Equity", there is a specific order to the phrase.
> 
> Your result will have to return like "XXXXXX UK XXXXX Equity" but not  
> "XXXXX Equity XXXX UK"
> 
> How I can implement this in Elasticsearch?
> 
> Please suggest.
> 
> Thanks,  
> Pulkit Agrawal

---

<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, 3:33am UTC](https://discuss.elastic.co/t/search-order-of-term-in-query/7263/3 "2017-07-06T03:33:10Z")

</div>


