Elasticsearch: 对索引的应用小写

2024-06-01 08:38:13 发布

您现在位置:Python中文网/ 问答频道 /正文

我在elasticsearch中索引了文档。示例文档如下所示:

{
    "_index": "processed_tweets",
    "_type": "processed",
    "_id": "830403820580663296",
    "_score": 1,
    "_source": {
      "at": [
        "@LouisDasch"
      ],
      "original_tweet_id": "830398288352403457",
      "id_str": "830403820580663296",
      "trigrams": [
        "blessed lourdes lady",
        "lourdes lady feast",
        "lady feast day",
        "feast day wishing"
      ],
      "hashtags": [
        "#Catholic"
      ],
      "id_tweet_creator": "487735029",
      "tokens": [
        "blessed",
        "lourdes",
        "lady",
        "feast",
        "day",
        "wishing"
      ],
      "bigrams": [
        "blessed lourdes",
        "lourdes lady",
        "lady feast",
        "feast day",
        "day wishing"
      ],
      "retweeted": true
    }
  }

我想把我索引的所有文档的“hashtags”字段中的所有hashtags都小写。 例如,我会: “hashtags”:[“#Catholic”]->;“hashtags”:[“#Catholic”] 将每个关键字更新为小写形式(保留“#”)的最佳方法是什么(节省时间)?你知道吗


Tags: 文档id示例elasticsearchtweet小写dayprocessed
1条回答
网友
1楼 · 发布于 2024-06-01 08:38:13

如果您使用的是ES5.0及更高版本,则会引入一种名为“painless”的脚本语言。这可能有助于您更新字段。它的处理速度很快。你知道吗

有关更多信息,请查看下面的链接。你知道吗

https://www.elastic.co/guide/en/elasticsearch/reference/5.0/modules-scripting-painless.html

相关问题 更多 >