当前位置:   article > 正文

es--基础--12--SpringBoot自定义逗号分词器_springboot分词器

springboot分词器

es–基础–12–SpringBoot自定义逗号分词


1、设置 代码输出资源

        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                    <include>**/*.yml</include>
                    <include>**/*.properties</include>
                    <include>**/*.json</include>
                </includes>
                <!-- 是否替换资源中的属性 -->
                <filtering>false</filtering>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*.xml</include>
                    <include>**/*.yml</include>
                    <include>**/*.properties</include>
                    <include>**/*.json</include>
                </includes>
                <!-- 是否替换资源中的属性 -->
                <filtering>false</filtering>
            </resource>

        </resources>

  • 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

在这里插入图片描述

2、配置分词器

2.1、分词器json

commaAnalyzer_setting.json

{
  "analysis": {
    "analyzer": {
      "comma": {
        "type": "pattern",
        "pattern": ","
      }
    }
  }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

在这里插入图片描述

2.2、代码 添加分词器

2.2.1、类上

@Setting(settingPath = "commaAnalyzer_setting.json")
  • 1

在这里插入图片描述

2.2.2、字段上

	@Field(type = FieldType.Text, analyzer = "comma",searchAnalyzer = "comma",store = true),
    private String fieldReaderAccount;  // 业务表-可读账户字段逗号分隔,全部可读使用

  • 1
  • 2
  • 3

2.3、查看索引信息

{
    "data_record": {
        "aliases": {},
        "mappings": {
            "properties": {
                "_class": {
                    "type": "keyword",
                    "index": false,
                    "doc_values": false
                }, 
                "fieldFlowStatus": {
                    "type": "keyword",
                    "store": true,
                    "ignore_above": 8100
                },
                "fieldReaderAccount": {
                    "type": "text",
                    "store": true,
                    "fields": {
                        "keyword": {
                            "type": "keyword",
                            "ignore_above": 8100
                        }
                    },
                    "analyzer": "comma"
                },
                "uuid": {
                    "type": "keyword",
                    "store": true,
                    "ignore_above": 8100
                }
            }
        },
        "settings": {
            "index": {
                "number_of_shards": "1",
                "provided_name": "data_record",
                "creation_date": "1679298135682",
                "analysis": {
                    "analyzer": {
                        "comma": {
                            "pattern": ",",
                            "type": "pattern"
                        }
                    }
                },
                "number_of_replicas": "1",
                "uuid": "w_bcdnFKQSmHdkziDvx64g",
                "version": {
                    "created": "7040299"
                }
            }
        }
    }
}

  • 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
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56

在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/610086
推荐阅读
相关标签
  

闽ICP备14008679号