3

I can't seem to get highlighting to work properly with Spring Boot and the Spring Data Solr package.

I'm using Spring Boot 1.4.1.

I have

public interface BooksRepository extends SolrCrudRepository<Books, String> {

    @Highlight(prefix = "<highlight>", postfix = "</highlight>")
    HighlightPage<SolrBooks> findByTitle(@Param("title") String title, Pageable pageable);

}

I see this in my logs.

webapp=/solr path=/select params={q=title:Matrix&hl=true&hl.simple.post=&start=0&hl.fl=*&rows=20&wt=javabin&version=2&hl.simple.pre=}

If I run the above query (without the wt=javabin) directly against Solr I get the Highlighting objects returned.

However my Spring Boot REST response doesn't include the Highlighting.

 {
  "_embedded" : {
    "Books" : [ {
      "Title" : "Matrix",
      "_links" : {
        "self" : {
          "href" : "http://localhost:8080/Books/329"
        },
        "Books" : {
          "href" : "http://localhost:8080/Books/329"
        }
      }
    } ]
  },
  "_links" : {
    "self" : {
      "href" : "http://localhost:8080/Books/search/findByTitle?title=Matrix"
    }
  },
  "page" : {
    "size" : 20,
    "totalElements" : 1,
    "totalPages" : 1,
    "number" : 0
  }
}

I feel I'm doing something stupid but this is pretty simply but it seems that Spring is omitting the Highlighting once Solr passes the information back to it. What am I doing wrong?

Kevin Vasko
  • 1,561
  • 3
  • 22
  • 45

1 Answers1

0

Use

@Highlight(prefix = "<highlight>", postfix = "</highlight>", fields = {"title"})