# Have we a way to use highlight and fuzzy together?

**URL:** <https://discuss.elastic.co/t/have-we-a-way-to-use-highlight-and-fuzzy-together/18435>\
**Category:** Elasticsearch\
**Created:** [July 2, 2014, 10:47am UTC](https://discuss.elastic.co/t/have-we-a-way-to-use-highlight-and-fuzzy-together/18435 "2014-07-02T10:47:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tanguy\_Bernard](https://avatars.discourse-cdn.com/v4/letter/t/839c29/32.png) [@Tanguy\_Bernard](https://discuss.elastic.co/u/Tanguy_Bernard)\
**Post date:** [July 2, 2014, 10:47am UTC](https://discuss.elastic.co/t/have-we-a-way-to-use-highlight-and-fuzzy-together/18435/1 "2014-07-02T10:47:33Z")

</div>

Hello  
Everything is on subject  
I have to use fuzzy for my fileds (title,content) and when I'm searching I  
want to see a part of the sentance where my keyword is.

This, together, doesn't work:  
$params['body']['highlight']['fields'][$value]['fragment\_size']=30;  
$params['body']['query']['fuzzy']=0.2;

Have we a way to use highlight and fuzzy together or an other way  
equivalent ?

Thank to you in advance.

--  
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/b6628cb4-7e2c-4e21-b578-a14865450a83%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b6628cb4-7e2c-4e21-b578-a14865450a83%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [July 2, 2014, 1:21pm UTC](https://discuss.elastic.co/t/have-we-a-way-to-use-highlight-and-fuzzy-together/18435/2 "2014-07-02T13:21:06Z")

</div>

On Wed, Jul 2, 2014 at 6:47 AM, Tanguy Bernard [bernardtanguy1pro@gmail.com](mailto:bernardtanguy1pro@gmail.com)  
wrote:

Hello

> Everything is on subject  
> I have to use fuzzy for my fileds (title,content) and when I'm searching I  
> want to see a part of the sentance where my keyword is.
> 
> This, together, doesn't work:  
> $params['body']['highlight']['fields'][$value]['fragment\_size']=30;  
> $params['body']['query']['fuzzy']=0.2;
> 
> Have we a way to use highlight and fuzzy together or an other way  
> equivalent ?

Usually its better to show a recreation with curl. PHP isn't always  
understood.

Vocabulary point: fuzzy, prefix, and regex queries are called "multi term  
queries".

Anyway, there are three highlighters built in to Elasticsearch all of which  
have different feature sets. I'm not sure if the plain highlighter  
supports multi term queries, but you can try the fast vector highlighter or  
the postings highlighter which do support multi term queries. See

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

For completeness sake I should mention that I maintain a fourth highlighter  
that also supports multi term queries but it is a plugin:

> **[GitHub - wikimedia/search-highlighter: Github mirror of "search/highlighter"...](https://github.com/wikimedia/search-highlighter)**
>
> Github mirror of "search/highlighter" - our actual code is hosted with Gerrit (please see https://www.mediawiki.org/wiki/Developer\_access for contributing - GitHub - wikimedia/search-high...

Nik

--  
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/CAPmjWd02ok9w%2B9U47bdmT78JvxP%3D41kpPBpOyRCGmXH71J4a5Q%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAPmjWd02ok9w%2B9U47bdmT78JvxP%3D41kpPBpOyRCGmXH71J4a5Q%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Tanguy\_Bernard](https://avatars.discourse-cdn.com/v4/letter/t/839c29/32.png) [@Tanguy\_Bernard](https://discuss.elastic.co/u/Tanguy_Bernard)\
**Post date:** [July 7, 2014, 10:05am UTC](https://discuss.elastic.co/t/have-we-a-way-to-use-highlight-and-fuzzy-together/18435/3 "2014-07-07T10:05:08Z")

</div>

I want to combine like this :

GET my\_index/my\_type/\_search?pretty=true  
{"size": 50,

"query": {  
_"fuzzy": 0.2,_  
"multi\_match": {  
"query": "my words",

```
        "fields": ["title_doc"]

    }
}, 
*"highlight" : {*

```

- 

```
   "order" : "date_doc",*

```

- 

```
   "fields" : {*

```

- 

```
       "title_doc" : { "fragment_size" : 30**}*

```

- 

```
   }*

```

- }\*

}

Can you help me ?

Tanguy

--  
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/8e56e849-ca0a-4c3c-9183-c928d4236e77%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8e56e849-ca0a-4c3c-9183-c928d4236e77%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Tanguy\_Bernard](https://avatars.discourse-cdn.com/v4/letter/t/839c29/32.png) [@Tanguy\_Bernard](https://discuss.elastic.co/u/Tanguy_Bernard)\
**Post date:** [July 7, 2014, 10:30am UTC](https://discuss.elastic.co/t/have-we-a-way-to-use-highlight-and-fuzzy-together/18435/4 "2014-07-07T10:30:04Z")

</div>

I want to combine like this :

GET my\_index/my\_type/\_search?pretty=true  
{"size": 50,

"query": {

```
    "multi_match": {
        "query": "my words",
       
        "fields": ["title_doc"]

    },*"fuzzy": 0.2*
}, 
*"highlight" : {*

```

- 

```
   "fields" : {*

```

- 

```
       "title_doc" : { "fragment_size" : 30**}*

```

- 

```
   }*

```

- },\*  
"sort": [  
{  
"date\_source": {  
"order": "desc"  
}  
}  
]

}

Can you help me ?

Tanguy

--  
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/af25f933-be1e-4df5-9c15-ab494b5d31b5%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/af25f933-be1e-4df5-9c15-ab494b5d31b5%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:17am UTC](https://discuss.elastic.co/t/have-we-a-way-to-use-highlight-and-fuzzy-together/18435/5 "2017-07-06T01:17:36Z")

</div>


