如何设置“索引” :“not_analyzed”全球弹性搜索 [英] how to set "index" : "not_analyzed" globally for elastic search
问题描述
我正面临一个问题,即如何设置index:not_analyzed,用于弹性搜索映射json格式文件中的字符串值,以便在进行报告时不会被标记。目前我单独做了这个检查。但是,当一个新的产品出现时会产生问题。
(使用弹性搜索版本1.7.2)
i'm facing a problem that how to set "index" : "not_analyzed" globally for the elastic search for string values in mapping json format file so that it will not get tokenized when making reports. Currently i have made that check individually. But,when a new property comes in it creates problem. (using elastic search version 1.7.2)
例如: - 如果我给一个新的字符串字段说地址,当一个值如bangalore印度进入,那么在作出报告的时候,它将被视为班加罗尔和印度两个独立的价值。
For example :- If i'm giving a new string field say address, when a value like "bangalore india" comes in, then it will get treated as 2 sepparate values as "Bangalore" and "india" while making reports.
这是一个示例json映射程序文件格式我在用着。让我知道如何在全球范围内设置相同的..
Here is a sample json mapper file format that i'm using. Let me know how i can set it globally for the same..
{
"user" : {
"_index" : {
"enabled" : true
},
"_id" : {
"index": "not_analyzed",
"store" : "yes"
},
"properties" : {
"id" : {
"type" : "long"
},
"name" : {
"type" : "string",
"index" : "not_analyzed"
},
"presentValue" : {
"type" : "string",
"index" : "not_analyzed"
},
"dateOfBirth" : {
"type" : "date"
}
}
}
}
推荐答案
您需要使用 dynamic_template
创建索引时。通过下面的动态字符串
映射,将动态创建的所有新字符串字段将为 not_analyzed
You need to use a dynamic_template
when creating your index. With the dynamic strings
mapping below, all new string fields that will be created dynamically will be not_analyzed
PUT my_index
{
"mappings": {
"user": {
"_index": {
"enabled": true
},
"_id": {
"store": "yes"
},
"dynamic_templates": [
{
"strings": {
"match_mapping_type": "string",
"match": "*",
"mapping": {
"type": "string",
"index": "not_analyzed"
}
}
}
],
"properties": {
"id": {
"type": "long"
},
"name": {
"type": "string",
"index": "not_analyzed"
},
"presentValue": {
"type": "string",
"index": "not_analyzed"
},
"dateOfBirth": {
"type": "date"
}
}
}
}
}
这篇关于如何设置“索引” :“not_analyzed”全球弹性搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!