elasticsearch 总是得到根Map定义具有不支持的参数错误

r7xajy2e  于 2023-06-05  发布在  ElasticSearch
关注(0)|答案(1)|浏览(170)

无法从文档创建最简单的Map

index_name = "index_test"

mapping = {
  "mappings": {
    "properties": {
      "age":    { "type": "integer" },
      "email":  { "type": "keyword"  },
      "name":   { "type": "text"  }
    }
  }
}

resp = es.indices.create(index=index_name, body=mapping)

版本
弹性传输==8.4.0
Elasticsearch==7.17.9
elasticsearch-dsl==7.4.1
出错了
elasticsearch.exceptions.RequestError:RequestError(400,'mapper_parsing_exception','根Map定义具有不支持的参数:[Map:{properties={name={type=text},age={type=integer},email={type=keyword}}}]')

72qzrwbm

72qzrwbm1#

当更新你的Map时,你不需要mappings部分,只需要像这样做:

mapping =  {
    "properties": {
      "age":    { "type": "integer" },
      "email":  { "type": "keyword"  },
      "name":   { "type": "text"  }
    }
}

index_name = "test_index"

es.indices.put_mapping(index=index_name, body=mapping, doc_type='test')

相关问题