1. ignore_above
關(guān)于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配置值的數(shù)據(jù),默認值
2147483647字符。注意:動態(tài)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 than?ignore_above
?will not be indexed or stored大于ignore_above設(shè)置的字符串將不會被索引或存儲。
注意:
All strings/array elements will still be present in the?
_source
?field, if the latter is enabled which is the default in Elasticsearch.默認所有的字符串/數(shù)組元素仍然會出現(xiàn)在_source字段中。
2.測試
創(chuàng)建索引 test_keyword,指定長度超過10的數(shù)據(jù)不索引
PUT test_keyword
{
"mappings": {
"properties": {
"name":{
"type":"keyword",
"ignore_above": 10
}
}
}
}
向索引中寫入數(shù)據(jù):
PUT test_keyword/_doc/1
{
"name":"1234567890"
}
PUT test_keyword/_doc/2
{
"name":"12345678901"
}
查詢數(shù)據(jù),結(jié)果如下:文章來源:http://www.zghlxwxcb.cn/news/detail-722510.html
#可以查詢到數(shù)據(jù)結(jié)果
GET test_keyword/_search
{
"query":{
"term": {
"name": "1234567890"
}
}
}
#查詢不到數(shù)據(jù)結(jié)果
GET test_keyword/_search
{
"query":{
"term": {
"name": "12345678901"
}
}
}
在查詢所有數(shù)據(jù)_source中可以看到“12345678901”這條數(shù)據(jù),說明“12345678901”這條數(shù)據(jù)沒有被索引。文章來源地址http://www.zghlxwxcb.cn/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"
}
}
]
}
}
到了這里,關(guān)于Elasticsearch keyword 中的 ignore_above配置項的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!