我必須更改從字符串到浮點映射中的價格字段類型。 當我想這更改映射字段類型elasticsearch 1.7
curl -XPUT http://52.73.2.239:9200/products/_mapping/product -d '{ "properties":{ "productOnly.price":{ "type" : "float" } } }'
但沒有什麼變化。 這裏是我的數據
"properties" : { //I some props and other objects. productOnly is nested object "productOnly" : { "properties" : { "bonus" : { "type" : "string" }, "price" : { "type" : "string" } } } }
您[無法這樣做](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html#updating-field-mappings),您需要創建另一個帶有'float'類型的字段並填充它,或者擦除你的索引,重新創建它並重新填充它。 – Val
但我可以在向我的索引添加數據之前創建映射嗎? –
是的,但是一旦你給了你的領域一定的類型,你就不能改變它。您必須刪除索引並用新類型重新創建索引。 – Val