# Prefix search with missing words

**URL:** <https://discuss.elastic.co/t/prefix-search-with-missing-words/154488>\
**Category:** Elasticsearch\
**Created:** [October 29, 2018, 6:39pm UTC](https://discuss.elastic.co/t/prefix-search-with-missing-words/154488 "2018-10-29T18:39:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ritz](https://avatars.discourse-cdn.com/v4/letter/r/13edae/32.png) [@ritz](https://discuss.elastic.co/u/ritz)\
**Post date:** [October 29, 2018, 6:39pm UTC](https://discuss.elastic.co/t/prefix-search-with-missing-words/154488/1 "2018-10-29T18:39:17Z")

</div>

Hello !  
I am trying to get a search on index where i want to search something similar to edge ngram where user will start typing beginning of a word and i expect the search result to return the best match. The only problem is seems like edge ngram works only if the search words are next to each other.  
What i want is example if the sentence is "quick brown fox jumps over the lazy dog" and if i specify the search as "brow lazy" i am unable to get the results. i don't know which api to use.  
Here are the things i researched so far  
1\>Tried Edge Ngram analyser: If the search has missing words search returns nothing  
2\>Terms query: This will return even if the words are not in the right sequence and also lot of irrelevant one's  
3\> match\_phrase\_prefix : This cannot be used if first few words are half complete

I have spend a lot of time researching this before posting this so any help from the elastic search gurus will be greatly appreciated 🙂

---

<div class="post-metadata">

**Author:** ![ritz](https://avatars.discourse-cdn.com/v4/letter/r/13edae/32.png) [@ritz](https://discuss.elastic.co/u/ritz)\
**Post date:** [October 29, 2018, 7:52pm UTC](https://discuss.elastic.co/t/prefix-search-with-missing-words/154488/2 "2018-10-29T19:52:27Z")

</div>

After some trial and error i git this partially working

{ "query": {  
"bool": {  
"must": [  
{"prefix" : { "idxName" : "brow" }},  
{"prefix" : { "idxName" : "jum" }},  
{"prefix" : { "idxName" : "lazy" }}

```
	]

```

}  
}  
}

'  
The problem now is there are some cases where it returns me results where these 3 words are not in the right sequence.  
Example if i have  
"Jump with lazy animal which is a brown dog " might showup in the search before the one which has the right sequence

---

<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:** [November 26, 2018, 7:52pm UTC](https://discuss.elastic.co/t/prefix-search-with-missing-words/154488/3 "2018-11-26T19:52:30Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
