# Writing a custom highlighter

**URL:** <https://discuss.elastic.co/t/writing-a-custom-highlighter/35067>\
**Category:** Elasticsearch\
**Created:** [November 19, 2015, 4:20pm UTC](https://discuss.elastic.co/t/writing-a-custom-highlighter/35067 "2015-11-19T16:20:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mos/32/4898_2.png) [@mos](https://discuss.elastic.co/u/mos)\
**Post date:** [November 19, 2015, 4:20pm UTC](https://discuss.elastic.co/t/writing-a-custom-highlighter/35067/1 "2015-11-19T16:20:31Z")

</div>

I checked the documentation and googled around ... but I can't find a nice documentation how to build a custom highlighter for elasticsearch.

I like to extend the plain-highlighter with some custom stuff (e.g. fragment size will be dynamic in relation where the keywords are found, stripping html and other stuff...)

Is it possible to do this with elasticsearch? I assume I need to write a plugin that somehow extends the plain-highlighter.

Any thoughts on this this? Is there a good ES V2.0 example of how to write a custom highlighter?

Thanks!!!!!

---

<div class="post-metadata">

**Author:** ![mos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mos/32/4898_2.png) [@mos](https://discuss.elastic.co/u/mos)\
**Post date:** [November 20, 2015, 12:30pm UTC](https://discuss.elastic.co/t/writing-a-custom-highlighter/35067/2 "2015-11-20T12:30:49Z")

</div>

Anyone?

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [November 20, 2015, 2:47pm UTC](https://discuss.elastic.co/t/writing-a-custom-highlighter/35067/3 "2015-11-20T14:47:36Z")

</div>

Wikimedia's plugin highlighter might have the functionality you need or at least provide the basis for how to write your own: [https://github.com/wikimedia/search-highlighter](https://github.com/wikimedia/search-highlighter)

---

<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 5, 2017, 11:36pm UTC](https://discuss.elastic.co/t/writing-a-custom-highlighter/35067/4 "2017-07-05T23:36:53Z")

</div>


