# Highlight partial matches?

**URL:** <https://discuss.elastic.co/t/highlight-partial-matches/9949>\
**Category:** Elasticsearch\
**Created:** [December 5, 2012, 9:28am UTC](https://discuss.elastic.co/t/highlight-partial-matches/9949 "2012-12-05T09:28:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![A\_Zed](https://avatars.discourse-cdn.com/v4/letter/a/eb8c5e/32.png) [@A\_Zed](https://discuss.elastic.co/u/A_Zed)\
**Post date:** [December 5, 2012, 9:28am UTC](https://discuss.elastic.co/t/highlight-partial-matches/9949/1 "2012-12-05T09:28:40Z")

</div>

I'm using ngrams to do partial matching. I would like to retrieve fragments  
of the documents that match the partial text, with highlighting.  
I have the highlight option in the query, but it works only for full text  
searches; for partial searches, the highlight entry is empty.  
I can always add the field to the "fields" section and get the results that  
way; but I would prefer to just get snippets (fragments)  
instead of the entire document. Any ideas?

--

---

<div class="post-metadata">

**Author:** ![A\_Zed](https://avatars.discourse-cdn.com/v4/letter/a/eb8c5e/32.png) [@A\_Zed](https://discuss.elastic.co/u/A_Zed)\
**Post date:** [December 5, 2012, 9:41am UTC](https://discuss.elastic.co/t/highlight-partial-matches/9949/2 "2012-12-05T09:41:52Z")

</div>

Found it. One must use the alias for the partial match in the highlight  
section. Works like a charm!

On Wednesday, December 5, 2012 1:28:40 AM UTC-8, A Zed wrote:

> I'm using ngrams to do partial matching. I would like to retrieve  
> fragments of the documents that match the partial text, with highlighting.  
> I have the highlight option in the query, but it works only for full text  
> searches; for partial searches, the highlight entry is empty.  
> I can always add the field to the "fields" section and get the results  
> that way; but I would prefer to just get snippets (fragments)  
> instead of the entire document. Any ideas?

--

---

<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:01am UTC](https://discuss.elastic.co/t/highlight-partial-matches/9949/3 "2017-07-06T03:01:23Z")

</div>


