【问题标题】:Spring Boot Solr HighlightPage doesn't return highlighted informationSpring Boot Solr HighlightPage 不返回突出显示的信息
【发布时间】:2016-11-08 01:26:27
【问题描述】:

我似乎无法突出显示以与 Spring Boot 和 Spring Data Solr 包一起正常工作。

我使用的是 Spring Boot 1.4.1。

我有

public interface BooksRepository extends SolrCrudRepository<Books, String> {

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

}

我在我的日志中看到了这一点。

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

如果我直接针对 Solr 运行上述查询(没有 wt=javabin),我会返回 Highlighting 对象。

但是我的 Spring Boot REST 响应不包括突出显示。

 {
  "_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
  }
}

我觉得我在做一些愚蠢的事情,但这很简单,但似乎一旦 Solr 将信息传递回 Spring,Spring 就会忽略突出显示。我做错了什么?

【问题讨论】:

    标签: java spring spring-boot spring-data-solr


    【解决方案1】:

    使用

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

    【讨论】:

      猜你喜欢
      • 2021-05-12
      • 1970-01-01
      • 1970-01-01
      • 2011-08-06
      • 1970-01-01
      • 2017-10-10
      • 2018-07-15
      • 2013-08-30
      • 1970-01-01
      相关资源
      最近更新 更多