gpt4 book ai didi

date - 如何在Elasticsearch映射中从 “_all”中排除所有数字和日期

转载 作者:行者123 更新时间:2023-12-03 01:52:35 25 4
gpt4 key购买 nike

我想从elasticsearch的“_all”字段中删除所有数字和日期。这样可以减小尺寸并提高性能。我以为可以通过使用dynamic_templates完成此操作,但我无法使其正常工作。

映射是这样的(为了简单起见,仅用于数字):

{
"mappings" : {
"log" : {
"dynamic_templates" : [{
"_Excl_numbers" : {
"match" : "*",
"match_mapping_type" : "long",
"mapping" : {
"type" : "long"
},
"include_in_all" : false
}
}
]
}
}
}

我使用的测试数据(索引类型=“log”):
POST: http://{{URL}}/{{TEST_INDEX}}/_bulk
{"index":{"_type" : "log", "_id" : "2" } }
{"level_array":{"id":2,"ingestDate":null},"path":"rvh","group":"U-17"}
{"index":{"_type" : "log", "_id" : "3" } }
{"level_array":{"id":3,"ingestDate":"2011-08-04"},"group":"U-12"}
{"index":{"_type" : "log", "_id" : "4" } }
{"level_array":{"id":4,"ingestDate":"2011-08-04T10:00:00"},"path":["rvh","fcl"],"group":"U-17"}
{"index":{"_type" : "log", "_id" : "5" } }
{"level_array":[{"id":5,"ingestDate":"2011-09-07"},{"id":5,"ingestDate":"2011-02-05"}],"titel":"0125-DCU-INTR-TST-17"}

现在,该查询应该没有任何结果,但是我这样做了:
{
"_source" : true,
"query" : {
"simple_query_string" : {
"query" : "2",
"analyze_wildcard" : true,
"default_operator" : "AND"
}
}
}

那么,如何更改映射以从“_all”字段中排除所有数字(以及日期, bool(boolean) 值等)?

ElasticSearch版本是2.3.4

最佳答案

您只是将include_in_all放在了错误的级别。它应该是:

  "dynamic_templates": [
{
"_Excl_numbers": {
"match": "*",
"match_mapping_type": "long",
"mapping": {
"type": "long",
"include_in_all": false
}
}
}
]

关于date - 如何在Elasticsearch映射中从 “_all”中排除所有数字和日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39167782/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com