addHighlightedField(java.lang.String) depricated from SearchRequestBuilder api in ES v5.6.2

I am upgrading ES from v2.3.3 to v5.6.2. Given below is the code written using api in v2.3.3-
SearchRequestBuilder searchBuilder = getSearchRequestBuilder().setQuery(query).setPostFilter(filterBuilder).setFetchSource(null, new String{"file.content"}).addHighlightedField("file.content");
In the v5.6.2 the addHighlightedField (java.lang.String) has been removed and this functionality is now being provided by field(java.lang.String) method of HighlightBuilder.

How can I replace addHighlightedField() method with the new field() method and what are the changes that I will have to make? Please help.

I'd recommend using the Rest client as the Transport Client is deprecated.
Also, I'd recommend using the latest 5.6 version or better move to 6.7.

See some documentation here about 5.6 series: https://www.elastic.co/guide/en/elasticsearch/client/java-rest/5.6/java-rest-high-search.html#java-rest-high-request-highlighting

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