我在我的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”]
将每个关键字更新为等同于小写字母的最佳方法(节省时间)是什么(保留“#”)?
最佳答案
如果您使用的是ES 5.0及更高版本,则会引入一种称为“无痛”的脚本语言。这可以帮助您更新字段。它的处理速度非常快。
检查下面的链接以获取更多信息。
https://www.elastic.co/guide/en/elasticsearch/reference/5.0/modules-scripting-painless.html