spring与es集成(elasticsearch学习笔记)

这篇博客详细记录了Spring与Elasticsearch的集成过程,包括实体类的定义和使用,旨在分享学习经验并帮助遇到同样问题的读者。
摘要由CSDN通过智能技术生成

本文仅用来记录平常学习所得,也希望能帮助到所有需要的人


实体类如下(Score类仅用来测试当序列不存在时生成新序列使用,Student是主要使用的测试类):

@Document(indexName = "test2",type = "score")
public class Score implements Serializable {
    @Id
    @Field(index = FieldIndex.not_analyzed,type = FieldType.Integer,store = true)
    private Integer id;
    @Field(index = FieldIndex.not_analyzed,type = FieldType.String,store = true)
    private String chinese;
    @Field(index = FieldIndex.not_analyzed,type = FieldType.String,store = true)
    private String math;
    @Field(index = FieldIndex.not_analyzed,type = FieldType.String,store = true)
    private String english;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getChinese() {
        return chinese;
    }

    public void setChinese(String chinese) {
        this.chinese = chinese;
    }

    public String getMath() {
        return math;
    }

    public void setMath(String math) {
        this.math = math;
    }

    public String getEnglish() {
        return english;
    }

    public void setEnglish(String english) {
        this.english = english;
    }
}

@Document(indexName = "test1",type = "student")
public class Student implements Serializable {
    /*@Id
    @Field(index = FieldIndex.not_analyzed,type = FieldType.String,store = true)
    private String id;*/
    @Field(index = FieldIndex.not_analyzed,type = FieldType.String,store = true)
    private String birthday;
    @Field(index = FieldIndex.not_analyzed,type = FieldType.String,store = true)
    private String studentNo;
    @Field(index = FieldIndex.not_analyzed,type = FieldType.String,store = true)
    private String sex;
    @Field(index = FieldIndex.not_analyzed,type = FieldType.String,store = true)
    private String classNo;
    @Field(index = FieldIndex.not_analyzed,type = FieldType.String,store = true)
    private String address;
    @Field(index = FieldIndex.not_analyzed,type = FieldType.String,store = true)
    private String name;
    @Field(index = FieldIndex.not_analyzed,type = Field
  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值