Skip to content

HighlightBuilder.Field: unable to set highlighting encoder for a field #32745

Closed
@jnizet

Description

@jnizet

Describe the feature:

I'm trying to set the Highlighting encoder option to "html" instead of leaving the default for a specific field, and the Java API apparently has no way to do that (although the ElasticSearch reference documentation says we can override all highlighting settings for each field).

HighlightBuilder and HighlightBuilder.Field both extend AbstractHighlighterBuilder. HighlightBuilder has an encoder(String) method, but HighlighBuilder.Field doesn't.

This is not only annoying, but also a security issue since using the default strategy opens the door to HTML injection.

Also, BTW, the javadoc of HighlightBuilder.encoder() says that the two allowed values are "styled" and "default", but the reference documentation says the possible values are "html" and "default".

Is there something I'm missing, or is it indeed a missing method in the API?

If it's a missing method in the API, my feature request is to add this missing method :-)

Note: I tried to ask the question on the forum before posting the issue, but got no answer in 7 days :-(

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions