springboot 集成solr

yml

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

pom.xml

    <!--solr 这里注意springboot 版本-->
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-data-solr</artifactId>
    </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 = "<font color='red'>", postfix = "</font>",fragsize = 10000)
//  HighlightPage<Product> findByContentMatches(String content, Pageable pageable);
  Page<Product> findByContentMatches(String content, Pageable pageable);
}

这里写图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值