Java client: unable to set highlighting encoder for a field

Hello.

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?

hi,
as far as I can see the javadocs for HighlightBuilder.encoder are wrong. It is either html or default, I think you are right. Would you like to send a PR to correct that?

I believe this specific setting (encoder) cannot be overridden per field, I did not find a way to do that either, not only using the java API but also at REST sending a json request.

Cheers
Luca

I will try sending a PR. Thanks for your reply.

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