簡體   English   中英

在elasticsearch中重新索引期間,小寫索引中的所有字段

[英]Lowercase all fields in an index during reindexing in elasticsearch

我想重新索引索引,在此過程中我想要小寫所有字段的值。 有什么方法可以做到這一點。

目前我已經查看了攝取管道,但是在其中你必須命名每個需要轉換為小寫的字段。

{
  "lowercase": {
    "field": "foo"
  }
}

我想要一些可以小寫所有字段值的東西,而不需要提到字段的名稱。

我建議在調用Reindex API時使用腳本。 在腳本中,您可以遍歷所有字段並將其值小寫。 這樣的事情應該有效:

POST _reindex
{
  "source": {
    "index": "source_index"
  },
  "dest": {
    "index": "target_index"
  },
  "script": {
    "source": "ctx._source.forEach((field, value) -> ctx._source[field] = value?.toLowerCase())}",
    "lang": "painless"
  }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM