我需要防止某些字段的值像“null”(null作为字符串)和 ""
(空字符串)从elasticsearch中获取索引,即,我应该能够获取在源字段中不包含这些字段的文档。
索引时Map中是否需要任何设置,例如在字段上使用自定义分析器?
p、 s:-我正在使用elasticsearch 7.6.1
我试过下面的答案,这就是为什么它不起作用-
{ "settings": {
"number_of_shards": "5",
"analysis": {
"normalizer": {
"my_normalizer": {
"char_filter": [
{
"type": "mapping",
"mappings": [
"null =>",
"\"\"\" =>"
]
}
],
"filter": [
"uppercase"
],
"type": "custom"
}
}
},
"number_of_replicas": "1"}}
响应错误-序列化设置中只允许值列表
即使我尝试了以下设置,也没有得到预期的结果:
{ "settings": {
"number_of_shards": "5",
"analysis": {
"char_filter": {
"my_filter": {
"type": "mapping",
"mappings": [
"null =>",
"\"\"\" =>"
]
}
},
"normalizer": {
"my_normalizer": {
"char_filter": [
"my_filter"
],
"filter": [
"uppercase"
],
"type": "custom"
}
}
},
"number_of_replicas": "1"}}
请求-getindexname/\u分析
{"normalizer":"my_normalizer","text":"null"}
回应-
{
"tokens": [
{
"token": "",
"start_offset": 4,
"end_offset": 4,
"type": "word",
"position": 0
}
]
}
预期React-
{
"tokens": []
}
1条答案
按热度按时间qnakjoqk1#
在分析器定义中使用Map字符过滤器,您可以实现它,下面是工作示例。
分析api
并返回令牌