当前位置:   article > 正文

Elasticsearch实现全文检索简单实现_elasticsearchrepository 获取数据库列表

elasticsearchrepository 获取数据库列表

Elasticsearch实现全文检索

搜索步骤

关键词 es 匹配 满足条件返回id集合 --> 通过id集合,查询mysql/mongodb数据库得到数据列表


数据初始化:

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

设计domain 想当于在Elasticsearch中创建需全文查询的库和表

/**
 * 目的地搜索对象
 */
@Getter
@Setter
@Document(indexName="wolf2w_destination",type="destination")
public class DestinationEs implements Serializable {
   

    public static final String INDEX_NAME = "wolf2w_destination";
    public static final String TYPE_NAME = "destination";
    @Id
    //@Field 每个文档的字段配置(类型、是否分词、是否存储、分词器 )
    @Field(store=true, index = false,type = FieldType.Keyword)
    private String id;  //攻略id

    @Field(index=true,store=true,type = FieldType.Keyword)
    private String name;

    @Field(index=true,analyzer="ik_max_word",store=true,searchAnalyzer="ik_max_word",type = FieldType.Text)
    private String info;
}
-----------------------------------------------------------------------
    /**
 * 游记搜索对象
 */
@Getter
@Setter
@Document(indexName="wolf2w_travel",type="travel")
public class TravelEs implements Serializable {
   

    public static final String INDEX_NAME = "wolf2w_travel";
    public static final String TYPE_NAME = "travel";

    //@Field 每个文档的字段配置(类
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/305711
推荐阅读
相关标签
  

闽ICP备14008679号