# Localized highlighting issue

**URL:** <https://discuss.elastic.co/t/localized-highlighting-issue/4494>\
**Category:** Elasticsearch\
**Created:** [May 28, 2011, 11:35am UTC](https://discuss.elastic.co/t/localized-highlighting-issue/4494 "2011-05-28T11:35:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![paranoiabla](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paranoiabla/32/2160_2.png) [@paranoiabla](https://discuss.elastic.co/u/paranoiabla)\
**Post date:** [May 28, 2011, 11:35am UTC](https://discuss.elastic.co/t/localized-highlighting-issue/4494/1 "2011-05-28T11:35:09Z")

</div>

Hi all,

so here's the thing: we have some products that have their name  
localized in several languages. The name is defined in Elasticsearch  
as following:

# === name: { de: "some german text", en: "some english text", nl: "some dutch text" }

It all works good - if I have to search I search not in the "name"  
field, but in "name.nl" or "name.en" depending on the chosen locale on  
the frontend.

My question is: is this the right way to handle localization?

Also, the highlighting doesn't work. I tried setting the highlighting  
with the Java API as:

# === searchRequestBuilder.addHighlightedField("\_source.name[en]"); searchRequestBuilder.addHighlightedField("name[en]"); searchRequestBuilder.addHighlightedField("name"); searchRequestBuilder.addHighlightedField("name.en"); searchRequestBuilder.addHighlightedField("\_source.name.en"); searchRequestBuilder.setHighlighterPreTags("**"); searchRequestBuilder.setHighlighterPostTags("**");

And as you can see I have specified different combinations, but I  
never receive the results surrounded by the 'b' tag. I know that the  
field must be declared as stored in the mapping, and that is exactly  
what I tried.

1. I tried to setup "name" as stored, and then here's how my mapping  
looked like  
===  
{"myproduct":{"properties":{"picture":{"type":"string"},"price":  
{"type":"string"},"description":{"dynamic":"true","properties":{"en":  
{"type":"string"}}},"name":  
{"store":"yes","type":"string"},"availableSizes":  
{"type":"string"},"en":{"type":"string"}}}}  
===

2. Then I tried to "name.en", and again the mapping:  
===  
{"myproduct":{"properties":{"picture":{"type":"string"},"price":  
{"type":"string"},"description":{"dynamic":"true","properties":{"en":  
{"type":"string"}}},"name":{"dynamic":"true","properties":{"en":  
{"type":"string"}}},"availableSizes":{"type":"string"},"name.en":  
{"store":"yes","type":"string"},"brandName":{"type":"string"},"url":  
{"type":"string"},"pk":{"type":"string"},"availableColors":  
{"type":"string"}}}}

3. The "name[en]", and here's the mapping:  
===  
{"myproduct":{"properties":{"picture":{"type":"string"},"price":  
{"type":"string"},"description":{"dynamic":"true","properties":{"en":  
{"type":"string"}}},"name":{"dynamic":"true","properties":{"en":  
{"type":"string"}}},"availableSizes":{"type":"string"},"brandName":  
{"type":"string"},"url":{"type":"string"},"pk":  
{"type":"string"},"name[en]":  
{"store":"yes","type":"string"},"availableColors":{"type":"string"}}}}  
===

4. Last I tried setting only "en" as stored, and here's the mapping:  
===  
{"myproduct":{"properties":{"picture":{"type":"string"},"price":  
{"type":"string"},"description":{"dynamic":"true","properties":{"en":  
{"type":"string"}}},"name":{"dynamic":"true","properties":{"en":  
{"type":"string"}}},"availableSizes":{"type":"string"},"en":  
{"store":"yes","type":"string"},"brandName":{"type":"string"},"url":  
{"type":"string"},"pk":{"type":"string"},"availableColors":  
{"type":"string"}}}}  
===

After each of these I tried to search for something that gives result,  
and I got no highlighting.

Does any of you have any idea how can I get a highlighting in my  
search results?

Thank you for your time.

---

<div class="post-metadata">

**Author:** ![fashionalwallet](https://avatars.discourse-cdn.com/v4/letter/f/839c29/32.png) [@fashionalwallet](https://discuss.elastic.co/u/fashionalwallet)\
**Post date:** [June 10, 2011, 3:48am UTC](https://discuss.elastic.co/t/localized-highlighting-issue/4494/2 "2011-06-10T03:48:41Z")

</div>

- deleted -

---

<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, 4:03am UTC](https://discuss.elastic.co/t/localized-highlighting-issue/4494/3 "2017-07-06T04:03:57Z")

</div>

Closed on July 6, 2017, 4:03am UTC


