gpt4 book ai didi

elasticsearch - 如何在 ES 中使用数组映射?

转载 作者:行者123 更新时间:2023-11-29 02:43:00 25 4
gpt4 key购买 nike

我想为 movies 创建一个映射,如下所示:

{
title: "The Artist",
genres: ["Drama", "Comedy"]
}

ElasticSearch documentation我看到这个例子:

"properties" : {
"message" : {"type" : "string"},
"tags" : {"type" : "string", "index_name" : "tag"},
...
}

然而,现在我很困惑..我期望看到的是:

 "properties" : {
"message" : {"type" : "string"},
"tags" : {"type" : "array"}
}

那么,为什么这个例子只是提供对另一个索引的引用呢?我将如何定义“标签”索引?或者,我什么时候使用该数组映射?

最佳答案

因此 ElasticSearch 不需要指定一个映射是一个数组。您可以使用方括号将任何映射视为数组:

{
title: ["The Artist", "Formerly known as Prince" ],
genres: ["Drama", "Comedy"],
...
}

看页面最后一句话:

We could, of course, name the field as tag and skip the index_name all together

“index_name”映射只允许你定义一个复数形式的别名,tag -> tags。

关于elasticsearch - 如何在 ES 中使用数组映射?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18902877/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com