springboot 集成solr

yml

spring:
    data:
        solr:
            host: http://localhost::8983/solr

pom.xml

    
    <dependency>
      <groupId>org.springframework.bootgroupId>
      <artifactId>spring-boot-starter-data-solrartifactId>
    dependency>

springboot 版本是1.5.9 开启solr自动配置 ,之前1.5.2 集成发送solr的http请求core重复
SolrDocument 注解指定solr core

/**
 * @author lcc
 */
@SolrDocument(solrCoreName = "kcore_onekey")
@data
public class Product {

  @Id
  @Field
  private String id;

  @Field(value = "CAPTURE_TIME")
  private long captureTime;


  @Field(value = "DETAILS")
  private String details;


  @Field(value = "CONTENT")
  private String content;

  @Field(value = "INFO_TYP")
  private int infoTyp;

  @Field(value = "_version_")
  private long version;
}

spring-date -jpa方式操作方便简介 可参考([https://projects.spring.io/spring-data-solr]

/**
 * @author lcc
 */
public interface ProductRepository extends SolrCrudRepository<Product, String> {
//fragsize 默认返回的高亮字段是有长度限制fragsize 可设置长度
//  @Highlight(prefix = "", postfix = "",fragsize = 10000)
//  HighlightPage findByContentMatches(String content, Pageable pageable);
  Page findByContentMatches(String content, Pageable pageable);
}

springboot 集成solr_第1张图片

你可能感兴趣的:(全文检索)