我正在尝试使用以下语法创建索引
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/