# Strong term/words order search with words between

**URL:** <https://discuss.elastic.co/t/strong-term-words-order-search-with-words-between/50147>\
**Category:** Elasticsearch\
**Created:** [May 16, 2016, 6:01pm UTC](https://discuss.elastic.co/t/strong-term-words-order-search-with-words-between/50147 "2016-05-16T18:01:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Max\_Just](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@Max\_Just](https://discuss.elastic.co/u/Max_Just)\
**Post date:** [May 16, 2016, 6:01pm UTC](https://discuss.elastic.co/t/strong-term-words-order-search-with-words-between/50147/1 "2016-05-16T18:01:05Z")

</div>

Hi, Is it possible to use elasticsearch for search all documents that contain 2-3 word with strong order, for example  
I want to get all docs cantains (by query "for mobiles"):

```auto
for mobile phones
for Apple and Adnroid mobile phones 
for table and mobile phones

```

but not this docs:

```auto
mobile phone for womens
mobile phones for teens

```

I am trying to use match\_phrase with slop, but it change words places if slop more than 2

Can anybody help?

---

<div class="post-metadata">

**Author:** ![mikemccand](https://avatars.discourse-cdn.com/v4/letter/m/f04885/32.png) [@mikemccand](https://discuss.elastic.co/u/mikemccand)\
**Post date:** [May 17, 2016, 3:20pm UTC](https://discuss.elastic.co/t/strong-term-words-order-search-with-words-between/50147/2 "2016-05-17T15:20:48Z")

</div>

Maybe try span near queries? You can specify whether the order must be preserved.

[https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-near-query.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-near-query.html)

Mike McCandless

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [May 17, 2016, 3:33pm UTC](https://discuss.elastic.co/t/strong-term-words-order-search-with-words-between/50147/3 "2016-05-17T15:33:36Z")

</div>

> [@mikemccand](#):
>
> Maybe try span near queries? You can specify whether the order must be preserved.

One problem with this approach is that those are _term_-style queries and not _match_-style queries. So they aren't pre-analyzed, IIRC.

---

<div class="post-metadata">

**Author:** ![Max\_Just](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@Max\_Just](https://discuss.elastic.co/u/Max_Just)\
**Post date:** [May 17, 2016, 3:35pm UTC](https://discuss.elastic.co/t/strong-term-words-order-search-with-words-between/50147/4 "2016-05-17T15:35:25Z")

</div>

Does it mean without morpological support?

---

<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:50pm UTC](https://discuss.elastic.co/t/strong-term-words-order-search-with-words-between/50147/5 "2017-07-05T22:50:58Z")

</div>


