# Does english analyzer prevent fields from highlighting?

**URL:** <https://discuss.elastic.co/t/does-english-analyzer-prevent-fields-from-highlighting/23013>\
**Category:** Elasticsearch\
**Created:** [March 31, 2015, 4:02pm UTC](https://discuss.elastic.co/t/does-english-analyzer-prevent-fields-from-highlighting/23013 "2015-03-31T16:02:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Viacheslav\_Shalamov](https://avatars.discourse-cdn.com/v4/letter/v/3ec8ea/32.png) [@Viacheslav\_Shalamov](https://discuss.elastic.co/u/Viacheslav_Shalamov)\
**Post date:** [March 31, 2015, 4:02pm UTC](https://discuss.elastic.co/t/does-english-analyzer-prevent-fields-from-highlighting/23013/1 "2015-03-31T16:02:56Z")

</div>

Hi all, could you help me with little problem regarding language-specific  
analyzers and highliting in elasticsearch?

I need search documents by a query string and highlight matched strings.  
Here is my mapping:  
{  
"usr": {  
"properties": {  
"text0": {  
"type": "string",  
"analyzer": "english"  
},  
"text1": {  
"type": "string"  
}  
}  
}  
}  
Note, that for "text0" field "english" analyzer is set, and for "text1"  
field is used standard analyzer by default.

In my index there is one document for now:

hits": [{  
"\_index": "tt",  
"\_type": "usr",  
"\_id": "AUxvIPAv84ayQMZV-3Ll",  
"\_score": 1,  
"\_source": {  
"text0": "highlighted. need to be highlighted.",  
"text1": "highlighted. need to be highlighted."  
}  
}]

Consider following query:  
{  
"query": {  
"query\_string" : {  
"query" : "_highlighted_"  
}  
},  
"highlight" : {  
"fields" : {  
"\*" : {}  
}  
}  
}

I've expected each field in the document to be highlighted, but  
highlighting appeared only in "text1" field (where is no analyzer set):

"hits": [{  
"\_type": "usr",  
"\_source": {  
"text0": "highlighted. need to be highlighted.",  
"text1": "highlighted. need to be highlighted."  
},  
"\_score": 0.19178301,  
"\_index": "tt",  
"highlight": {  
"text1": [  
"_highlighted_. need to be _highlighted_."  
]  
},  
"\_id": "AUxvIPAv84ayQMZV-3Ll"  
}]

Let's consider the following query(I expected "highlighted" matches  
"highlight" because of analyzer):  
{  
"query": {  
"query\_string" : {  
"query" : "_highlight_"  
}  
},  
"highlight" : {  
"fields" : {  
"\*" : {}  
}  
}  
}

But there was no hist in response at all: (Did the english analyzer even  
work here?)  
"hits": {  
"hits": [],  
"total": 0,  
"max\_score": null  
}

At last, consider some curl commands (requests and responses):

curl "[http://localhost:9200/tt/\_analyze?field=text0](http://localhost:9200/tt/_analyze?field=text0)" -d "highlighted"

{"tokens":[{  
"token":"_highlight_",  
"start\_offset":0,  
"end\_offset":11,  
"type":"",  
"position":1  
}]}

curl "[http://localhost:9200/tt/\_analyze?field=text1](http://localhost:9200/tt/_analyze?field=text1)" -d "highlighted"

{"tokens":[{  
"token":"_highlighted_",  
"start\_offset":0,  
"end\_offset":11,  
"type":"",  
"position":1  
}]}

We see, by passing text through the english and standard analyzers, the  
result is different.  
Finally, the question:  
_does english analyzer prevent fields from highlighting? How can I get my  
fields highlighted while full-text search?_  
P.S. I use elasticsearch v1.4.4 on my local machine with windows 8.1.

--  
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/59cea72f-08e3-42b2-ad0e-e5d5ba7762a8%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/59cea72f-08e3-42b2-ad0e-e5d5ba7762a8%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:** [March 31, 2015, 10:20pm UTC](https://discuss.elastic.co/t/does-english-analyzer-prevent-fields-from-highlighting/23013/2 "2015-03-31T22:20:24Z")

</div>

Using inline highlighters doesn't help highlighting. No. For the most  
part you should stay away from inline analyzers and use a mapping instead.

On Tue, Mar 31, 2015 at 12:02 PM, Viacheslav Shalamov \<[sslavian812@gmail.com](mailto:sslavian812@gmail.com)

> wrote:

> Hi all, could you help me with little problem regarding language-specific  
> analyzers and highliting in elasticsearch?
> 
> I need search documents by a query string and highlight matched strings.  
> Here is my mapping:  
> {  
> "usr": {  
> "properties": {  
> "text0": {  
> "type": "string",  
> "analyzer": "english"  
> },  
> "text1": {  
> "type": "string"  
> }  
> }  
> }  
> }  
> Note, that for "text0" field "english" analyzer is set, and for "text1"  
> field is used standard analyzer by default.
> 
> In my index there is one document for now:
> 
> hits": [{  
> "\_index": "tt",  
> "\_type": "usr",  
> "\_id": "AUxvIPAv84ayQMZV-3Ll",  
> "\_score": 1,  
> "\_source": {  
> "text0": "highlighted. need to be highlighted.",  
> "text1": "highlighted. need to be highlighted."  
> }  
> }]
> 
> Consider following query:  
> {  
> "query": {  
> "query\_string" : {  
> "query" : "_highlighted_"  
> }  
> },  
> "highlight" : {  
> "fields" : {  
> "\*" : {}  
> }  
> }  
> }
> 
> I've expected each field in the document to be highlighted, but  
> highlighting appeared only in "text1" field (where is no analyzer set):
> 
> "hits": [{  
> "\_type": "usr",  
> "\_source": {  
> "text0": "highlighted. need to be highlighted.",  
> "text1": "highlighted. need to be highlighted."  
> },  
> "\_score": 0.19178301,  
> "\_index": "tt",  
> "highlight": {  
> "text1": [  
> "_highlighted_. need to be _highlighted_."  
> ]  
> },  
> "\_id": "AUxvIPAv84ayQMZV-3Ll"  
> }]
> 
> Let's consider the following query(I expected "highlighted" matches  
> "highlight" because of analyzer):  
> {  
> "query": {  
> "query\_string" : {  
> "query" : "_highlight_"  
> }  
> },  
> "highlight" : {  
> "fields" : {  
> "\*" : {}  
> }  
> }  
> }
> 
> But there was no hist in response at all: (Did the english analyzer even  
> work here?)  
> "hits": {  
> "hits": ,  
> "total": 0,  
> "max\_score": null  
> }
> 
> At last, consider some curl commands (requests and responses):
> 
> curl "[http://localhost:9200/tt/\_analyze?field=text0](http://localhost:9200/tt/_analyze?field=text0)" -d "highlighted"
> 
> {"tokens":[{  
> "token":"_highlight_",  
> "start\_offset":0,  
> "end\_offset":11,  
> "type":"",  
> "position":1  
> }]}
> 
> curl "[http://localhost:9200/tt/\_analyze?field=text1](http://localhost:9200/tt/_analyze?field=text1)" -d "highlighted"
> 
> {"tokens":[{  
> "token":"_highlighted_",  
> "start\_offset":0,  
> "end\_offset":11,  
> "type":"",  
> "position":1  
> }]}
> 
> We see, by passing text through the english and standard analyzers, the  
> result is different.  
> Finally, the question:  
> _does english analyzer prevent fields from highlighting? How can I get my  
> fields highlighted while full-text search?_  
> P.S. I use elasticsearch v1.4.4 on my local machine with windows 8.1.
> 
> --  
> 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/59cea72f-08e3-42b2-ad0e-e5d5ba7762a8%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/59cea72f-08e3-42b2-ad0e-e5d5ba7762a8%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/59cea72f-08e3-42b2-ad0e-e5d5ba7762a8%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/59cea72f-08e3-42b2-ad0e-e5d5ba7762a8%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/CAPmjWd3m3mR2OMu6nbQG-9fVh04YOL\_qTjqyn-%3DKqNPAdoeHuA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAPmjWd3m3mR2OMu6nbQG-9fVh04YOL_qTjqyn-%3DKqNPAdoeHuA%40mail.gmail.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, 12:22am UTC](https://discuss.elastic.co/t/does-english-analyzer-prevent-fields-from-highlighting/23013/3 "2017-07-06T00:22:34Z")

</div>


