# Highlighting multi-valued fields

**URL:** <https://discuss.elastic.co/t/highlighting-multi-valued-fields/5697>\
**Category:** Elasticsearch\
**Created:** [October 26, 2011, 7:28pm UTC](https://discuss.elastic.co/t/highlighting-multi-valued-fields/5697 "2011-10-26T19:28:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matthew\_A\_Brown](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matthew_a_brown/32/2699_2.png) [@Matthew\_A\_Brown](https://discuss.elastic.co/u/Matthew_A_Brown)\
**Post date:** [October 26, 2011, 7:28pm UTC](https://discuss.elastic.co/t/highlighting-multi-valued-fields/5697/1 "2011-10-26T19:28:40Z")

</div>

Hello,

I'm starting to work with highlighting and one thing I'm noticing is  
I'm not able to get the results I'd like when highlighting  
multi-valued fields. For instance, say I have the following document:

{ "tags": ["pizza", "fried chicken"] }

Ideally, if searching for "chicken", I'd like to be able to highlight  
in such a way that I can extract "fried chicken" as distinct from  
"pizza" from the returned fragment(s). The only behavior I can get,  
though, is to return "pizza fried chicken" in a single fragment.

I believe this could be accomplished using the LuceneGapFragmenter:  
[http://javasourcecode.org/html/open-source/solr/solr-3.2.0/org/apache/solr/highlight/LuceneGapFragmenter.html](http://javasourcecode.org/html/open-source/solr/solr-3.2.0/org/apache/solr/highlight/LuceneGapFragmenter.html)

The idea here is that each value in a multi-valued field is buffered  
by a large position increment, and then the GapFragmenter looks for  
those and cuts off fragments at large gaps. I'm not sure if ES is  
already putting position increment gaps in place -- if so, it would  
just be a matter of using the GapFragmenter to perform the  
fragmenting.

So, does ES expose this functionality today in a way that I've missed?  
If not, would it be feasible to put it in place? Happy to submit a  
ticket if so.

Thanks,  
Mat

---

<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, 3:50am UTC](https://discuss.elastic.co/t/highlighting-multi-valued-fields/5697/2 "2017-07-06T03:50:48Z")

</div>


