# How to get the count of the pre or post tags in the highlight fragment?

**URL:** <https://discuss.elastic.co/t/how-to-get-the-count-of-the-pre-or-post-tags-in-the-highlight-fragment/214639>\
**Category:** Elasticsearch\
**Created:** [January 10, 2020, 4:48pm UTC](https://discuss.elastic.co/t/how-to-get-the-count-of-the-pre-or-post-tags-in-the-highlight-fragment/214639 "2020-01-10T16:48:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sgomez](https://avatars.discourse-cdn.com/v4/letter/s/ea5d25/32.png) [@sgomez](https://discuss.elastic.co/u/sgomez)\
**Post date:** [January 10, 2020, 4:48pm UTC](https://discuss.elastic.co/t/how-to-get-the-count-of-the-pre-or-post-tags-in-the-highlight-fragment/214639/1 "2020-01-10T16:48:06Z")

</div>

Hi,

I have a query that has highlight fields. I was wondering if there's a way to get the count of pre or post tags on the fragment on java.

For example if the fragment of my highlight field is something like "_john_ Johnson _smith_". The count of pre tags would be 2.

Regards,

---

<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:** [February 7, 2020, 4:56pm UTC](https://discuss.elastic.co/t/how-to-get-the-count-of-the-pre-or-post-tags-in-the-highlight-fragment/214639/2 "2020-02-07T16:56:31Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
