elasticsearch - Elasticsearch 7无法创建索引

标签 elasticsearch

我正在尝试使用以下语法创建索引

curl -H "Content-Type: application/json" -XPUT 127.0.0.1:9200/movies -d '
{
    "mappings": {
        "movie": {
            "properties": {
                "year": {"type":"date"}
            }
        }
    }
}'

我想“电影”不能成为“映射”的子代,有人可以帮助我将其转换为Elasticsearch 7兼容语法。

我尝试使用"movie.year" : {"type":"date"},但随后的插入语句失败
curl -H "Content-Type: application/json" -XPUT 127.0.0.1:9200/movies/movie/109487 -d '
{
    "genre":["IMAX", "Sci-Fi"],
    "title":"Intersteller",
    "year":2014
}'

我从Elasticsearch 6教程复制

"Rejecting mapping update to [movies] as the final mapping would have more than 1 type: [_doc, movie]"

最佳答案

在ES 7中,存在no more types。您需要这样做。

首先,create the index:

curl -H "Content-Type: application/json" -XPUT 127.0.0.1:9200/movies -d '
{
    "mappings": {
        "properties": {
            "year": {"type":"date"}
        }
    }
}'

然后,index your document:
curl -H "Content-Type: application/json" -XPUT 127.0.0.1:9200/movies/_doc/109487 -d '
{
    "genre":["IMAX", "Sci-Fi"],
    "title":"Intersteller",
    "year":2014
}'

关于elasticsearch - Elasticsearch 7无法创建索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57585321/

相关文章:

elasticsearch - 无法在MultiMatch查询中将模糊性设置为自动

elasticsearch - Elasticsearch比较两个字段

elasticsearch - Elasticsearch路由分配意识和分片分配

elasticsearch - Elasticsearch token 位置与得分相关吗?

elasticsearch - Elasticsearch用于设置索引 “no”使用哪种类型,关键字还是文本?

elasticsearch - 动态模板支持默认类型吗?

elasticsearch - 在DateRangeQuery中进行比较的方式是哪种?

elasticsearch - Spring Data Elasticsearch嵌套字段多匹配查询

python-3.x - 通过从目录中读取所有.txt文件来创建一个JSON对象

elasticsearch - 按比例计算修整平均值