Highlight part ignored in the spring data @Query

I'm using spring data elasticsearch @Query annotation, i don't get the highlighted values returned from this query, it works fine on elasticsearch

{
	"from":0,
	"size":1,
	"highlight": {
      "fields": {
         "code": {
            "pre_tags": [
               "<strong>"
            ],
            "post_tags": [
               "</strong>"
            ],
            "fragment_size": 500,
            "number_of_fragments": 3
         },
         "name": {
            "pre_tags": [
               "<strong>"
            ],
            "post_tags": [
               "</strong>"
            ],
            "fragment_size": 500,
            "number_of_fragments": 3
         }
      }
   },
	"query": {
		"multi_match": {
			"query": "xyz",
			"fields": ["code^2", "name"],
			"analyzer": "standard"
			}
	}
}

You should ask in spring data project then.

@dadoonet okay, did you know any forum for spring data and elasticsearch?

@smhdiu Hi Mohsin, I can't get the highlighted fields with this Repo query code, any thought on it, I'm using 4.0.0.RC2:

@Query("{\n" +
            "  \"multi_match\": {\n" +
            "    \"query\": \"?0\",\n" +
            "    \"fields\": [\n" +
            "      \"code^2\",\n" +
            "      \"name\"\n" +
            "    ],\n" +
            "    \"analyzer\": \"standard\"\n" +
            "  }\n" +
            "}")
    @Highlight(
            fields = @HighlightField(
                    name = "['code','name']"),
            parameters = @HighlightParameters(
                    preTags = "<strong>",
                    postTags = "</strong>",
                    fragmentSize = 500,
                    numberOfFragments = 3
            )
    )
    List<CodeNames> findAllByCodeAndNameOrderByName(String code, Pageable pageable);

Apparently they are now using stackoverflow. https://stackoverflow.com/tags/spring-data

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