我希望能够在我的 ES 索引中存储一个 json 对象。这是我尝试存储的示例(这是一个序列化模型,一个发送到 ES 的请求正文):
"{"id":218,"name":"Test2","category_id":1,"address":"Pushkin street","phone":null,"site":null,"location":{"lat":64,"lon":70},"city":"Heaven","description":"Super company","tags":["#test1","#test2"]}"
当我尝试存储它时(当然是通过扩展名),这是 ES 返回的错误:
"{"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"failed to parse [location]"}],"type":"mapper_parsing_exception","reason":"failed to parse [location]","caused_by":{"type":"illegal_argument_exception","reason":"unknown property [lat]"}},"status":400}"
如果没有特定的类型映射,我似乎无法这样做,例如在文档中: https ://www.elastic.co/guide/en/elasticsearch/reference/1.4/mapping-object-type.html
但是,我似乎没有找到在模型中提供该映射的方法。扩展的文档并没有真正说明它。所以,我的问题是:我是否需要它,如果需要,怎么做?
感谢所有反馈。