# Plain Highlighter using document-defined analyzer

**URL:** <https://discuss.elastic.co/t/plain-highlighter-using-document-defined-analyzer/17487>\
**Category:** Elasticsearch\
**Created:** [May 13, 2014, 4:22pm UTC](https://discuss.elastic.co/t/plain-highlighter-using-document-defined-analyzer/17487 "2014-05-13T16:22:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mateusz\_Kaczynski](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mateusz_kaczynski/32/1206_2.png) [@Mateusz\_Kaczynski](https://discuss.elastic.co/u/Mateusz_Kaczynski)\
**Post date:** [May 13, 2014, 4:22pm UTC](https://discuss.elastic.co/t/plain-highlighter-using-document-defined-analyzer/17487/1 "2014-05-13T16:22:13Z")

</div>

We have recently encountered a problem with item highlighting when we  
changed the way we define analysers.

In short, the problem boiled down to PlainHighlighter using analyser for  
the document type. while we  
specify analyser on per-document basis. '\_analyzer' field is not used (or,  
from my debugging, even visible) in the highlighter context. As a temporary  
solution, I made highlighter use the field to which '\_analyzer' points  
to(via path) in the mappings we use,

My attempt at it is over here:

> <https://github.com/arachnys/elasticsearch/commit/8082fcab5e22f783536f226eb544da7c27ceabba>

There are a couple of issues that I am seeking help with:

1. Does this seem like an about - right approach to dealing with the  
situation?
2. Analyzer field name is hardcoded, as I was unable to figure out how to  
get it from the document in the correct way (again, the right field is  
pointed to in '\_analyzer' via path). Any suggestions how to do it properly?

Regards,  
Mateusz Kaczyński

--  
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/7bbf3576-5fb1-44d1-badd-90f6b6cdf2d1%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/7bbf3576-5fb1-44d1-badd-90f6b6cdf2d1%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Mateusz\_Kaczynski](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mateusz_kaczynski/32/1206_2.png) [@Mateusz\_Kaczynski](https://discuss.elastic.co/u/Mateusz_Kaczynski)\
**Post date:** [May 16, 2014, 2:28pm UTC](https://discuss.elastic.co/t/plain-highlighter-using-document-defined-analyzer/17487/2 "2014-05-16T14:28:29Z")

</div>

Any thoughts on this?

On Tuesday, 13 May 2014 16:22:13 UTC, Mateusz Kaczynski wrote:

> We have recently encountered a problem with item highlighting when we  
> changed the way we define analysers.
> 
> In short, the problem boiled down to PlainHighlighter using analyser for  
> the document type. while we  
> specify analyser on per-document basis. '\_analyzer' field is not used (or,  
> from my debugging, even visible) in the highlighter context. As a temporary  
> solution, I made highlighter use the field to which '\_analyzer' points  
> to(via path) in the mappings we use,
> 
> My attempt at it is over here:
> 
> [Plain highlighter should use document 'language\_analyzer' field to de… · arachnys/elasticsearch@8082fca · GitHub](https://github.com/arachnys/elasticsearch/commit/8082fcab5e22f783536f226eb544da7c27ceabba)
> 
> There are a couple of issues that I am seeking help with:
> 
> 1. Does this seem like an about - right approach to dealing with the  
> situation?
> 2. Analyzer field name is hardcoded, as I was unable to figure out how to  
> get it from the document in the correct way (again, the right field is  
> pointed to in '\_analyzer' via path). Any suggestions how to do it properly?
> 
> Regards,  
> Mateusz Kaczyński

--  
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/d2962d64-26d6-4984-835a-e6b3bee7731c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d2962d64-26d6-4984-835a-e6b3bee7731c%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:28am UTC](https://discuss.elastic.co/t/plain-highlighter-using-document-defined-analyzer/17487/3 "2017-07-06T01:28:52Z")

</div>


