# Highlight feature - limitToMaxAnalyzedOffset - does still exist?

**URL:** <https://discuss.elastic.co/t/highlight-feature-limittomaxanalyzedoffset-does-still-exist/271644>\
**Category:** Elasticsearch\
**Created:** [April 29, 2021, 1:08pm UTC](https://discuss.elastic.co/t/highlight-feature-limittomaxanalyzedoffset-does-still-exist/271644 "2021-04-29T13:08:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jlarroque](https://avatars.discourse-cdn.com/v4/letter/j/6a8cbe/32.png) [@jlarroque](https://discuss.elastic.co/u/jlarroque)\
**Post date:** [April 29, 2021, 1:08pm UTC](https://discuss.elastic.co/t/highlight-feature-limittomaxanalyzedoffset-does-still-exist/271644/1 "2021-04-29T13:08:17Z")

</div>

Hi everyone, I was wondering if you could help me.

I found an interesting feature added in a specific PR:

> <https://github.com/elastic/elasticsearch/pull/67325>
>
> Add a \`max\_analyzed\_offset\` query parameter to allow users
> to limit the highlighting of text fields to a value less than or equal to the
> \`index.highlight.max\_analyzed\_offset\`, thus avoiding an exception when
> the length of the text field exceeds the limit. The highlighting still takes place,
> but stops at the length defined by the new parameter.
> 
> Closes: #52155

But I can't find documentation of how to use that using java HighLevel rest client. Was that removed?

That PR was for 7.12, and I'm using 7.8.1

---

<div class="post-metadata">

**Author:** ![jlarroque](https://avatars.discourse-cdn.com/v4/letter/j/6a8cbe/32.png) [@jlarroque](https://discuss.elastic.co/u/jlarroque)\
**Post date:** [April 29, 2021, 1:19pm UTC](https://discuss.elastic.co/t/highlight-feature-limittomaxanalyzedoffset-does-still-exist/271644/2 "2021-04-29T13:19:17Z")

</div>

I'm confused right now. Is that only allowed for .NET client?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 29, 2021, 1:45pm UTC](https://discuss.elastic.co/t/highlight-feature-limittomaxanalyzedoffset-does-still-exist/271644/3 "2021-04-29T13:45:31Z")

</div>

You need 7.12. I just tried this:

```auto
    @Test
    void highlight() throws IOException {
        try {
            client.indices().delete(new DeleteIndexRequest("highlight"), RequestOptions.DEFAULT);
        } catch (ElasticsearchStatusException ignored) {
        }
        client.index(new IndexRequest("highlight").source("{\"foo\":\"bar\"}", XContentType.JSON), RequestOptions.DEFAULT);
        client.indices().refresh(new RefreshRequest("highlight"), RequestOptions.DEFAULT);
        client.search(new SearchRequest("highlight").source(
                new SearchSourceBuilder()
                    .query(QueryBuilders.matchQuery("foo", "bar"))
                    .highlighter(new HighlightBuilder().field("foo").maxAnalyzedOffset(10)
                    )
                ), RequestOptions.DEFAULT);
    }

```

---

<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:** [May 27, 2021, 1:45pm UTC](https://discuss.elastic.co/t/highlight-feature-limittomaxanalyzedoffset-does-still-exist/271644/4 "2021-05-27T13:45:36Z")

</div>

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