使用Elasticsearch版本7
我的目的是用3个部分定义动态Map:
1.动态区域(所有字符串和数组将动态添加)
1.添加所有其他已知字段的静态Map。
1.拒绝动态Map之上的所有已知字段
我成功的处理了动态Map+静态区域(1,2段),可惜deny段不能创建。
随附单据-
{
"_index": "index_test",
"_type": "_doc",
"_id": "8ed19f94-11e2-417c-998d-a21275d7fb18",
"_score": 1.0,
"_source": {
/ *********************************** known static mapping as free text *********** /
"source": "S3 Large Bucket of Files",
"scanner_type_group": "unstructured",
"my_type": "file",
/ ************************************** dynamic fileds *********** /
"dynamic_field_1": "S3 Large Bucket of Files",
"dynamic_field_2": " foo 123",
"fullyQualifiedName": "S3 Large Bucket of Files.hyper-scan-test",
"columnOrFieldOccurrencesCounter": [
{
"fieldName": "fileContent"
}
],
/************************************* Ignore these fileds *********** /
"longNumber": 1622721252657,
"floatNumber": 1.6227213E12,
"discard1": " This static field should be ignored!!!",
"discard2": " This static field should be ignored too!!!",
"discard_array": [" aaa" ,"sss"]
}
}
到目前为止,我创建了Map/设置,但没有拒绝部分:(
{
"dynamic_templates": [
{
"strings_as_keywords": {
"match_mapping_type": "string",
"mapping": {
"type": "text",
"analyzer": "autocomplete"
}
}
}
],
"properties": {
"source": { "type": "keyword" },
"scanner_type_group": { "type": "keyword" },
"my_type": { "type": "keyword" }
},
// How ignore the following property not indexed to ES ???
// 1. ignore all numeric types from dynamic mappings
// 2. ignore other static mappings name: and array name discard_array
// 3. choose ignore either to store with/without index
}
文本的设置(它工作)
{
"analysis": {
"filter": {
"autocomplete_filter": {
"type": "ngram",
"min_gram": 2,
"max_gram": 20
}
},
"analyzer": {
"autocomplete": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"lowercase",
"autocomplete_filter"
]
}
}
},
"max_ngram_diff": 30,
"index": {
"number_of_shards": 5,
"number_of_replicas": 0
}
}
任何建议如何忽略数值类型和特定字段+数组(如JSON中所述)。
谢谢
1条答案
按热度按时间ejk8hzay1#
要忽略特定的字段(您知道其中的名称和类型),可以将indexMap参数设置为
false
。这将保留源中的字段,但不会扩大索引。您不能/不应该搜索这些字段!