从ElasticSearch索引设置中清除char_filter

bbuxkriu  于 2022-12-11  发布在  ElasticSearch
关注(0)|答案(1)|浏览(116)

如何从索引设置中清除char_filter定义?
我有以下索引设置,其中char_filter已定义并在默认分析器中使用。

GET /indexName/_settings
{
    "settings": {
        "analysis": {
            "char_filter": {
                "custom_filter": {
                    "type": "mapping",
                    "mappings": [
                        "Customer@Cloud => Customer_at_Cloud"
                    ]
                }
            },
            "analyzer": {
                "default": {
                    "char_filter": [
                        "custom_filter"
                    ]
                }
            }
        }
    }
}

清除char_filter对象没有帮助

PUT /indexName/_settings
{
    "settings": {
        "analysis": {
            "char_filter": null
            },
            "analyzer": {
                "default": {
                    "char_filter": [ ]
                }
            }
        }
    }
}

我可以i)覆盖默认分析器中的char_filter并将其设置为空,以便不使用char_filter,还可以ii)将custom_filterMap更新为空。但我想知道如何删除custom_filter定义。我尝试按如下方式清除,但没有效果。
第一次
我确实在更新索引设置之前关闭了索引。我正在避免删除索引并创建一个具有所需设置的新索引,这很有效。

wwwo4jvm

wwwo4jvm1#

我认为你在更新设置时做错了什么。这里给你举个例子。当你逐一尝试下面的命令时。你可以看到它起作用了:

PUT indexb
{
  "settings": {
    "analysis": {
      "char_filter": {
        "custom_filter": {
          "type": "mapping",
          "mappings": [
            "Customer@Cloud => Customer_at_Cloud"
          ]
        }
      },
      "analyzer": {
        "default": {
          "type": "custom",
          "tokenizer": "standard",
          "char_filter": [
            "custom_filter"
          ]
        }
      }
    }
  }
}

GET indexb/_settings

POST indexb/_close

PUT indexb/_settings
{
  "analysis": {
    "char_filter": {
      "custom_filter": {
        "type": "mapping",
        "mappings": []
      }
    }
  }
}

POST indexb/_open

GET indexb/_settings

最后,下面是我们在设置响应时得到的结果:

{
  "indexb": {
    "settings": {
      "index": {
        "routing": {
          "allocation": {
            "include": {
              "_tier_preference": "data_content"
            }
          }
        },
        "number_of_shards": "1",
        "provided_name": "indexb",
        "creation_date": "1670702801437",
        "analysis": {
          "analyzer": {
            "default": {
              "type": "custom",
              "char_filter": [
                "custom_filter"
              ],
              "tokenizer": "standard"
            }
          },
          "char_filter": {
            "custom_filter": {
              "type": "mapping",
              "mappings": []
            }
          }
        },
        "number_of_replicas": "1",
        "uuid": "AW14oRJKRhCe11kbxcxkuw",
        "version": {
          "created": "8050299"
        }
      }
    }
  }
}

最后,我只是尝试使用Elasticsearch 8.5.2。

相关问题