1. ignore_above
关于es mapping的keyword ignore_above配置项的解释如下:
Do not index any string longer than this value. Defaults to
2147483647
so that all values would be accepted.不会索引大于ignore_above配置值的数据,默认值
2147483647字符。注意:动态mappings中自动为256。
Strings longer than the
ignore_above
setting will not be indexed or stored. For arrays of strings,ignore_above
will be applied for each array element separately and string elements longer thanignore_above
will not be indexed or stored大于ignore_above设置的字符串将不会被索引或存储。
注意:
All strings/array elements will still be present in the
_source
field, if the latter is enabled which is the default in Elasticsearch.默认所有的字符串/数组元素仍然会出现在_source字段中。
2.测试
创建索引 test_keyword,指定长度超过10的数据不索引
PUT test_keyword
{
"mappings": {
"properties": {
"name":{
"type":"keyword",
"ignore_above": 10
}
}
}
}
向索引中写入数据:
PUT test_keyword/_doc/1
{
"name":"1234567890"
}
PUT test_keyword/_doc/2
{
"name":"12345678901"
}
查询数据,结果如下:文章来源:https://www.toymoban.com/news/detail-722510.html
#可以查询到数据结果
GET test_keyword/_search
{
"query":{
"term": {
"name": "1234567890"
}
}
}
#查询不到数据结果
GET test_keyword/_search
{
"query":{
"term": {
"name": "12345678901"
}
}
}
在查询所有数据_source中可以看到“12345678901”这条数据,说明“12345678901”这条数据没有被索引。文章来源地址https://www.toymoban.com/news/detail-722510.html
GET test_keyword/_search
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 2,
"relation" : "eq"
},
"max_score" : 1.0,
"hits" : [
{
"_index" : "test_keyword",
"_type" : "_doc",
"_id" : "1",
"_score" : 1.0,
"_source" : {
"name" : "1234567890"
}
},
{
"_index" : "test_keyword",
"_type" : "_doc",
"_id" : "2",
"_score" : 1.0,
"_ignored" : [
"name"
],
"_source" : {
"name" : "12345678901"
}
}
]
}
}
到了这里,关于Elasticsearch keyword 中的 ignore_above配置项的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!