美文网首页
elasticsearch keyword ignore_abo

elasticsearch keyword ignore_abo

作者: 念䋛 | 来源:发表于2022-05-15 14:00 被阅读0次

创建 mapping 时,可以为字符串(专指 keyword) 指定 ignore_above ,用来限定字符长度。超过 ignore_above 的字符会被存储,但不会被索引。

创建索引

127.0.0.1:9200/ceshi put请求

创建映射

127.0.0.1:9200/ceshi/_mapping put请求
body
{
    "properties": {
        "name": {
            "type": "keyword",
            "ignore_above": 10, //超过10个字符串长度
            "index": true
        }
    }
}

创建数据

127.0.0.1:9200/ceshi/_doc/_bulk
body
{"index": {}}
{"name":"0123456"}
{"index": {}}
{"name":"0123456789"}
{"index": {}}
{"name":"01234567890"} //操作了10个

查询数据

127.0.0.1:9200/ceshi/_search
{
    "query":{
        "match":{
            "name":"0123456" //可以查到数据,只有一条{"name":"0123456"}
                                          //01234567890 查询不到了,因为操过10个字符,该值不能被索引
        }
    }
}

相关文章

网友评论

      本文标题:elasticsearch keyword ignore_abo

      本文链接:https://www.haomeiwen.com/subject/yntburtx.html