# How to implement fuzzy search for phrase/phrase\_prefix in elasticsearch6.8?

**URL:** https://discuss.elastic.co/t/how-to-implement-fuzzy-search-for-phrase-phrase-prefix-in-elasticsearch6-8/185551
**Category:** Elasticsearch
**Created:** [June 13, 2019, 6:36am UTC](https://discuss.elastic.co/t/how-to-implement-fuzzy-search-for-phrase-phrase-prefix-in-elasticsearch6-8/185551 "2019-06-13T06:36:48Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![sunweiconfidence](https://avatars.discourse-cdn.com/v4/letter/s/58956e/32.png) [@sunweiconfidence](https://discuss.elastic.co/u/sunweiconfidence)
#### Post date: [June 13, 2019, 6:36am UTC](https://discuss.elastic.co/t/how-to-implement-fuzzy-search-for-phrase-phrase-prefix-in-elasticsearch6-8/185551/1 "2019-06-13T06:36:48Z")

</div>

hi  
i want to know how to implement fuzzy search for match/match\_phrase/match\_phrase\_prefix in elasticsearch6.8? previously i implement it using below clause in es5.4  
"match" : {  
"\_all" : {  
"query" : "test",  
"operator" : "and",  
"boost" : 1,  
"fuzziness" : 0.75,  
"prefix\_length" : 0,  
"max\_expansions" : 100  
}  
}  
but in es6.8, i use below clause to implement it  
{  
"multi\_match" : {  
"query" : "test",  
"type" : "phrase",  
"boost" : 1,  
"fuzziness" : 0.75,  
"prefix\_length" : 0,  
"max\_expansions" : 100  
}  
}  
but search meet with below exception:  
{"error":{"root\_cause":[{"type":"parsing\_exception","reason":"Fuzziness not allowed for type [phrase]"

any solution can solve the problem for it? or other method? thanks`Preformatted text`

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [June 13, 2019, 7:07am UTC](https://discuss.elastic.co/t/how-to-implement-fuzzy-search-for-phrase-phrase-prefix-in-elasticsearch6-8/185551/2 "2019-06-13T07:07:05Z")

</div>

why are you using `type: phrase` in the 6.8 example, but not in the 5.4 example? Those end up being two different queries. Also one is a `match` query and one if a `multi_match` query and the `operator` is different as well. Those will end up as very different queries being executed, so I am wondering if you are trying to create a new query or resemble the behaviour of the old query.

Also the `_all` field has been disabled by default in 6.x.

---

<div class="post-metadata">

### Author: ![sunweiconfidence](https://avatars.discourse-cdn.com/v4/letter/s/58956e/32.png) [@sunweiconfidence](https://discuss.elastic.co/u/sunweiconfidence)
#### Post date: [June 13, 2019, 7:30am UTC](https://discuss.elastic.co/t/how-to-implement-fuzzy-search-for-phrase-phrase-prefix-in-elasticsearch6-8/185551/3 "2019-06-13T07:30:03Z")

</div>

`because _all field is disabled, so i can't use match combining with _all, but i want to search all documents that crawling mongodb collection's fields with value to elasticsearch's index, i try multi_match to combine phrase search without fuzziness, it's ok and search effect is same as using match combine _all for es5.4, but es6.8 don't support phrase with fuzziness`

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [June 13, 2019, 7:46am UTC](https://discuss.elastic.co/t/how-to-implement-fuzzy-search-for-phrase-phrase-prefix-in-elasticsearch6-8/185551/4 "2019-06-13T07:46:58Z")

</div>

Why don't you either enable the all field again or use the workaround described in the deprecation warning at [https://www.elastic.co/guide/en/elasticsearch/reference/6.8/mapping-all-field.html](https://www.elastic.co/guide/en/elasticsearch/reference/6.8/mapping-all-field.html) ?

---

<div class="post-metadata">

### Author: ![sunweiconfidence](https://avatars.discourse-cdn.com/v4/letter/s/58956e/32.png) [@sunweiconfidence](https://discuss.elastic.co/u/sunweiconfidence)
#### Post date: [June 13, 2019, 8:07am UTC](https://discuss.elastic.co/t/how-to-implement-fuzzy-search-for-phrase-phrase-prefix-in-elasticsearch6-8/185551/5 "2019-06-13T08:07:27Z")

</div>

`i have adopt the multi_match solution, whether _all field also can be enabled in elasticsearch7 and above version? because later i also need to upgrade to es7, except for this all field workaround, do i have other option for it?`

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [June 13, 2019, 8:30am UTC](https://discuss.elastic.co/t/how-to-implement-fuzzy-search-for-phrase-phrase-prefix-in-elasticsearch6-8/185551/6 "2019-06-13T08:30:09Z")

</div>

please take the time to read my last message and the included link, where I explicitely mentioned a workaround that is laid out in the documentation, as this exact feature is removed in 7.0 but can be rebuild in a different manner.

---

<div class="post-metadata">

### Author: ![sunweiconfidence](https://avatars.discourse-cdn.com/v4/letter/s/58956e/32.png) [@sunweiconfidence](https://discuss.elastic.co/u/sunweiconfidence)
#### Post date: [June 14, 2019, 1:42am UTC](https://discuss.elastic.co/t/how-to-implement-fuzzy-search-for-phrase-phrase-prefix-in-elasticsearch6-8/185551/7 "2019-06-14T01:42:57Z")

</div>

ok, thanks

---

<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 12, 2019, 1:43am UTC](https://discuss.elastic.co/t/how-to-implement-fuzzy-search-for-phrase-phrase-prefix-in-elasticsearch6-8/185551/8 "2019-07-12T01:43:08Z")

</div>

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