Elasticsearch 2.x:geo_point 与 Mongodb 和 Mongoosastic 出错
Elasticsearch 2.x: Error with geo_point with Mongodb and Mongoosastic
哟!过去几天在使用 elasticsearch 2.x 中的 'geo_point' 映射时解决此错误时遇到了一些问题。在尝试映射我的模拟数据以包含 'geo_point' 时,当 运行 执行以下脚本时,我在控制台中收到错误消息:
curl -XDELETE localhost:9200/users
curl -XPOST localhost:9200/users -d "{"mappings":{"user":{"properties":{"coords":{"type":"geo_point"}}}}}"
{"error":{"root_cause":[{"type":"parse_exception","reason":"failed to parse source for create index"}],"type":"parse_exception","reason":"failed to parse source for create index","caused_by":{"type":"json_parse_exception","reason":"Unrecognized token 'geo_point': was expecting ('true', 'false' or 'null')\n at [Source: [B@4d7cc1ea; line: 1, column: 56]"}},"status":400}%
我的模拟数据如下:
{
...
"coords": [-84.370829, 33.756670] //<lon, lat>
...
}
它默认将我的 'coords' 保存为 double 类型。在使用我的 mongodb 集合中的数据为 ES 播种之前,我确保 运行 上面的脚本。我可以使用他们的 geoNear 函数查询 Mongo 就好了,但出于性能原因,需要 ES 来执行地理查询。
任何帮助都会很棒!
由于您的 JSON 包含双引号,您只需使用单引号...
curl -XPOST localhost:9200/users -d '{"mappings":{"user":{"properties":{"coords":{"type":"geo_point"}}}}}'
...或在 JSON
中转义双引号
curl -XPOST localhost:9200/users3 -d "{\"mappings\":{\"user\":{\"properties\":{\"coords\":{\"type\":\"geo_point\"}}}}}"
哟!过去几天在使用 elasticsearch 2.x 中的 'geo_point' 映射时解决此错误时遇到了一些问题。在尝试映射我的模拟数据以包含 'geo_point' 时,当 运行 执行以下脚本时,我在控制台中收到错误消息:
curl -XDELETE localhost:9200/users
curl -XPOST localhost:9200/users -d "{"mappings":{"user":{"properties":{"coords":{"type":"geo_point"}}}}}"
{"error":{"root_cause":[{"type":"parse_exception","reason":"failed to parse source for create index"}],"type":"parse_exception","reason":"failed to parse source for create index","caused_by":{"type":"json_parse_exception","reason":"Unrecognized token 'geo_point': was expecting ('true', 'false' or 'null')\n at [Source: [B@4d7cc1ea; line: 1, column: 56]"}},"status":400}%
我的模拟数据如下:
{
...
"coords": [-84.370829, 33.756670] //<lon, lat>
...
}
它默认将我的 'coords' 保存为 double 类型。在使用我的 mongodb 集合中的数据为 ES 播种之前,我确保 运行 上面的脚本。我可以使用他们的 geoNear 函数查询 Mongo 就好了,但出于性能原因,需要 ES 来执行地理查询。
任何帮助都会很棒!
由于您的 JSON 包含双引号,您只需使用单引号...
curl -XPOST localhost:9200/users -d '{"mappings":{"user":{"properties":{"coords":{"type":"geo_point"}}}}}'
...或在 JSON
中转义双引号curl -XPOST localhost:9200/users3 -d "{\"mappings\":{\"user\":{\"properties\":{\"coords\":{\"type\":\"geo_point\"}}}}}"