1

When we send multiple fields to be highlighted , the request that is sent to elastic search has only the last added field.

I observed the below issue in the integration between Spring-Data-ElasticSearch 3.0.0.RC2 and elasticsearch 5.5.0

The issue has already been raised with no solution - elastic search 5.5 highlight field is not working

I have elaborated my findings below

Mulitple Fields are being passed in the below code

org.springframework.data.elasticsearch.core.ElasticsearchTemplate

private SearchResponse doSearch(SearchRequestBuilder searchRequest, SearchQuery searchQuery)
{
    if (searchQuery.getHighlightFields() != null) {
            for (HighlightBuilder.Field highlightField : searchQuery.getHighlightFields()) {
                searchRequest.highlighter(new HighlightBuilder().field(highlightField));
            }
        }
}

org.elasticsearch.action.search.SearchRequestBuilder

 public SearchRequestBuilder highlighter(HighlightBuilder highlightBuilder) {
        sourceBuilder().highlighter(highlightBuilder);
        return this;
    }

Finally in org.elasticsearch.search.builder.SearchSourceBuilder , only the last HighlightBuilder that was set is considered

 public SearchSourceBuilder highlighter(HighlightBuilder highlightBuilder) {
        this.highlightBuilder = highlightBuilder;
        return this;
    }

I have raised the issue again , since it looks to me like the elastic search API is not able to support multiple highlight fields. I debugged the ElasticSearchTemplate in Spring Data and found that all the highlighted fields are passed correctly.

Kindly advise if there is any error in the way I am invoking the search.

lives
  • 1,243
  • 5
  • 25
  • 61
  • Found a work around for this issue Refer https://stackoverflow.com/questions/46752784/elastic-search-5-5-highlight-field-is-not-working – lives Oct 28 '17 at 06:13

0 Answers0