zoukankan      html  css  js  c++  java
  • es ik 分词 5.x后,设置默认分词

    1.使用模板方式,设置默认分词

    注: 设置模板,需要重新导入数据,才生效

    通过模板设置全局默认分词器
    
    curl -XDELETE http://localhost:9200/_template/rtf
    
    
    curl -XPUT http://localhost:9200/ _template/rtf
    -d'
    {
      "template":   "*", 
      "settings": { "number_of_shards": 1 }, 
      "mappings": {
        "_default_": {
          "_all": { 
            "enabled": true
          },
          "dynamic_templates": [
            {
              "strings": { 
                "match_mapping_type": "string",
                "mapping": {
                  "type": "text",
                  "analyzer":"ik_max_word",
                  "ignore_above": 256,
                  "fields": {
                    "keyword": {
                      "type":  "keyword"
                    }
                  }
                }
              }
            }
          ]
        }
      }
    }
    '

    2.单个设置分词(github上的例子)

    curl -XPOST http://localhost:9200/index/fulltext/_mapping -H 'Content-Type:application/json' -d'
    {
            "properties": {
                "content": {
                    "type": "text",
                    "analyzer": "ik_max_word",
                    "search_analyzer": "ik_max_word"
                }
            }
    
    }'
    curl -XPOST http://localhost:9200/索引/类型/_mapping -H 'Content-Type:application/json' -d'
    {
            "properties": {
                "字段": {
                    "type": "text",
                    "analyzer": "ik_max_word",
                    "search_analyzer": "ik_max_word"
                }
            }
    
    }'

    注: 设置如果 遇到 

                {
                    "type": "illegal_argument_exception",
                    "reason": "Mapper for [content] conflicts with existing mapping in other types:
    [mapper [content] has different [analyzer]]"
                }

    从错误提示上来看是说要创建的映射已经存在了,问题的关键就在于我没有创建过叫index的索引

    解决:重新导入数据,不做查询的情况下(查询了的话,会默认创建一个mapping),设置_mapping

  • 相关阅读:
    ansible tower
    gitlab说明书
    新建系统配置
    docker&k8s-配置/常用命令
    Winscp隧道实现-跳板机/跨机连接
    FDM, FVM, FEM
    批量处理文件
    未来的职业规划
    内心两大矛盾
    MATLAB在Linux下的安装方法(待尝试)
  • 原文地址:https://www.cnblogs.com/yjhkhnuje/p/10097227.html
Copyright © 2011-2022 走看看