go - 无法从类型 [geo_point] 更改为 xxx
问题描述
映射类型是geo_point,golang应该用什么类型
我的结构:
我的代码:
结果消息:
[400 Bad Request] {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"mapper [localhost] cannot be changed from type [geo_point] to [float]"}],"type":"illegal_argument_exception","reason":"mapper [localhost] cannot be changed from type [geo_point] to [float]"},"status":400}
解决方案
在不知道您正在运行的查询的情况下,我可以想象您没有为 geo_point 字段类型传递正确的格式。
根据文档,您需要传递lat
和lon
属性对象。
映射
PUT my-index-000001
{
"mappings": {
"properties": {
"location": {
"type": "geo_point"
}
}
}
}
摄取数据
PUT my-index-000001/_doc/1
{
"text": "Geo-point as an object",
"location": {
"lat": 41.12,
"lon": -71.34
}
}
询问
GET /my-index-000001/_search
{
"query": {
"bool": {
"must": {
"match_all": {}
},
"filter": {
"geo_distance": {
"distance": "200km",
"location": {
"lat": 40,
"lon": -70
}
}
}
}
}
}
如果您需要更多帮助,请附上您当前的查询
推荐阅读
- user-interface - Flutter Widget 显示嵌套树结构?
- r - 条件连接数据帧 R
- java - 计算 Stream 中的元素,但只考虑 N 来收集
- hasura - 如何在 hasura graphql 引擎上上传文件或图像
- sql - 将日期与 SQL 中的日期块进行比较
- python - 仅在 Jupyter 笔记本中显示 OpenAI 健身房
- php - php - 插入新数据时丢失旧数据
- javascript - 函数调用的区别
- node.js - 尽管通过 firewall-cmd 启用,但无法访问端口 3001 上的 express/node 服务器
- php - Mysql & PHP 查找值在两个日期和其他记录值之间的记录