1

我想知道如何将每个调用的字段设置"location"为 type "geo_point"

我可以为此使用默认映射吗?如果是,我找不到任何例子。

还是我应该使用动态模板?

谢谢

4

1 回答 1

3

您可以使用动态模板。以下是创建索引时如何执行此操作的示例:

 curl -XPOST localhost:9200/test -d '{
"settings": {
    "number_of_shards": 1
},
"mappings": {
    "_default_:": {
        "_ttl": true,
        "dynamic_templates": [
            {
                "geo_location": {
                    "mapping": {
                        "type": "geo_point"
                    },
                    "match": "location"
                }
            }
        ]
    }
}
}'
于 2013-04-22T18:15:38.610 回答