# Elasticsearch Highlighting problem

**URL:** <https://discuss.elastic.co/t/elasticsearch-highlighting-problem/12134>\
**Category:** Elasticsearch\
**Created:** [May 27, 2013, 8:55am UTC](https://discuss.elastic.co/t/elasticsearch-highlighting-problem/12134 "2013-05-27T08:55:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tasos\_Stathopoulos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tasos_stathopoulos/32/2294_2.png) [@Tasos\_Stathopoulos](https://discuss.elastic.co/u/Tasos_Stathopoulos)\
**Post date:** [May 27, 2013, 8:55am UTC](https://discuss.elastic.co/t/elasticsearch-highlighting-problem/12134/1 "2013-05-27T08:55:44Z")

</div>

I am trying to upgrade from 0.20.x to 0.90.0 and I am facing the following  
problem.

I have an index where I keep some blog posts. And when I am search for a  
blogpost I use elasticsearch highlighting. This was working perfectly with  
versions prior to 0.90.0.

In the latest version, elasticsearch does not return the highlight element  
when along with the hits. When I used the fast-vector-highlighter  
everything works fine.

I managed to narrow down the causes of this problem and I found out that  
the highlighting with the plain highlighter is not working when i use a  
pattern tokenizer. These are the declarations of the analyzer:

my\_analyzer:  
type: custom  
tokenizer: more-whitespace

more-whitespace:  
type: pattern  
pattern: ([\n\t.,!\/"']+)

Here is how I reproduce the problem:

curl -XPUT '[http://localhost:9200/test/?pretty](http://localhost:9200/test/?pretty)' -d '{  
"index" : true,  
"settings": {  
"number\_of\_shards" : 1  
},  
"_default_": {  
"include\_in\_all" : true  
},  
"mappings" : {  
"blog\_post" : {  
"type" : "object",  
"\_all" : {"enabled" : true, analyzer: "my\_analyzer"},  
"\_source": {"enabled" : true, "compress" : true},  
"properties": {  
"title": {  
"type" : "string",  
"index" : "analyzed",  
"analyzer" : "my\_analyzer",  
"include\_in\_all" : true  
},  
"body": {  
"type":"string",  
"index":"analyzed",  
"analyzer" : "my\_analyzer",  
"include\_in\_all" : true  
}  
}  
}  
}  
}'

{  
"ok" : true,  
"acknowledged" : true  
}

curl -XPUT '[http://localhost:9200/test/blog\_post/1](http://localhost:9200/test/blog_post/1)' -d '{  
"title" : "Some interesting title",  
"body" : "Some interesting body"  
}'

{"ok":true,"\_index":"test","\_type":"blog\_post","\_id":"1","\_version":1}

curl -XGET  
'[http://localhost:9200/test/blog\_post/\_search?routing=arkon&pretty](http://localhost:9200/test/blog_post/_search?routing=arkon&pretty)' -d '{  
"query": {  
"match" : {  
"\_all" : {  
"query" : "interesting"  
}}},  
"highlight" : {  
"pre\_tags" : ["\<span class="highlight"\>"],  
"post\_tags" : [""],  
"fields" : {"body" : {}, "title": {}}}  
}  
'

{  
"took" : 2,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 1,  
"successful" : 1,  
"failed" : 0  
},  
"hits" : {  
"total" : 1,  
"max\_score" : 0.16273327,  
"hits" : [ {  
"\_index" : "test",  
"\_type" : "blog\_post",  
"\_id" : "1",  
"\_score" : 0.16273327, "\_source" : {  
"title" : "Some interesting title",  
"body" : "Some interesting body"  
}  
} ]  
}

If I use the fast-vector-highlighter:

curl -XDELETE '[http://localhost:9200/test/](http://localhost:9200/test/)'

{"ok":true,"acknowledged":true }

curl -XPUT '[http://localhost:9200/test/](http://localhost:9200/test/)' -d '{  
"index" : true,  
"settings": {  
"number\_of\_shards" : 1  
},  
"_default_": {  
"include\_in\_all" : true  
},  
"mappings" : {  
"blog\_post" : {  
"type" : "object",  
"\_all" : {"enabled" : true, analyzer: "my\_analyzer"},  
"\_source": {"enabled" : true, "compress" : true},  
"properties": {  
"title": {  
"type" : "string",  
"index" : "analyzed",  
"analyzer" : "my\_analyzer",  
"term\_vector" : "with\_positions\_offsets",  
"include\_in\_all" : true  
},  
"body": {  
"type":"string",  
"index":"analyzed",  
"analyzer" : "my\_analyzer",  
"term\_vector" : "with\_positions\_offsets",  
"include\_in\_all" : true  
}  
}  
}  
}  
}'

{"ok":true,"acknowledged":true}

curl -XPUT '[http://localhost:9200/test/blog\_post/1](http://localhost:9200/test/blog_post/1)' -d '{  
"title" : "Some interesting title",  
"body" : "Some interesting body"  
}'

{"ok":true,"\_index":"test","\_type":"blog\_post","\_id":"1","\_version":1}

curl -XGET  
'[http://localhost:9200/test/blog\_post/\_search?routing=arkon&pretty](http://localhost:9200/test/blog_post/_search?routing=arkon&pretty)' -d '{  
"query": {  
"match" : {  
"\_all" : {  
"query" : "interesting"  
}}},  
"highlight" : {  
"pre\_tags" : ["\<span class="highlight"\>"],  
"post\_tags" : [""],  
"fields" : {"body" : {}, "title": {}}}  
}  
'  
{  
"took" : 14,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 1,  
"successful" : 1,  
"failed" : 0  
},  
"hits" : {  
"total" : 1,  
"max\_score" : 0.16273327,  
"hits" : [ {  
"\_index" : "test",  
"\_type" : "blog\_post",  
"\_id" : "1",  
"\_score" : 0.16273327, "\_source" : {  
"title" : "Some interesting title",  
"body" : "Some interesting body"  
},  
"highlight" : {  
"body" : [ "Some \<span class="highlight"\>interesting body"  
],  
"title" : [ "Some \<span class="highlight"\>interesting  
title" ]  
}  
} ]  
}

The same output I have with the plain hightlighter and whitespace tokenizer.

For now, I use the fast-vector-highlighter which solves the problem because  
I can't change my tokenizer. But I wanted to ask If is something wrong with  
my configuration or my index mapping or an unidentified bug.

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:34am UTC](https://discuss.elastic.co/t/elasticsearch-highlighting-problem/12134/2 "2017-07-06T02:34:37Z")

</div>


