elasticsearch - 如何从ElasticSearch中的文件导入GEO_TYPE

标签 elasticsearch

使用以下查询创建索引。 Elastic Search在Windows上运行。

curl -XPUT http://localhost:9200/us_large_cities -d  "{"""mappings""": {"""city""": {"""properties""": {"""city""": {"""type""": """string"""},"""state""": {"""type""": """string"""},"""location""": {"""type""": """geo_point"""}}}}}"

使用以下命令创建文档。
curl -XPOST http://localhost:9200/us_large_cities/city/ -d "{"""city""": """Birmingham""", """state""": """AL""","""location""": {"""lat""": """33.5206608""", """lon""": """-86.8024900"""}}"

使用命令一切运行正常。但是当我想使用以下查询使用json文件导入数据时。
curl -XPOST localhost:9200/us_large_cities/city/_bulk?pretty --data-binary "@citylocation.txt"

它给我错误。

'错误类型:Illegal_argumaent_exception'

'原因: Action /元数据行[1]格式错误,预期为START_OBJECT或END_OBJECT,但出现[VALUE STRING]

我的文件数据是:

{“city”:“伯明翰”,“state”:“AL”,“location”:{“lat”:“33.5206608”,“long”:“-86.8024900”}}

{“city”:“Huntsville”,“state”:“AL”,“location”:{“lat”:“34.7303688”,“long”:“-86.5861037”}}

{“城市”:“移动设备”,“州”:“AL”,“位置”:{“lat”:“30.6943566”,“long”:“-88.0430541”}}

最佳答案

您需要先放置元数据字段,然后再放置数据字段。
理想情况下,文本文件应以以下格式保存数据

{ "index" : { "_index" : "us_large_cities", "_type" : "city" } }
{"city": "Birmingham", "state": "AL","location": {"lat" : 33.5206608, "long" : -86.8024900}}
{ "index" : { "_index" : "us_large_cities", "_type" : "city" } }
{"city": "Mobile", "state": "AL","location": {"lat" : 30.6943566, "long" : -88.0430541}}

关于elasticsearch - 如何从ElasticSearch中的文件导入GEO_TYPE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37677388/

相关文章:

elasticsearch - 如何设置elasticsearch并发处理20k POST请求?

c# - 在NEST中创建IndexName的实例

Dockerized Elasticsearch 节点不可用于 Liferay 7.1

elasticsearch - 在同一映射中使用not_analyzed和Analyzer时会发生什么?

ElasticSearch/Lucene 查询字符串 — 选择 "field X exists"

elasticsearch - 更改elasticsearch中的_score以使其等于doc的score字段

scala - elastic4s:rawQuery 得分保持在 1

elasticsearch - 确保使用 Ansible 下载二进制文件的幂等性的最佳实践是什么?

elasticsearch - 由于yml配置,FileBeat服务无法启动

elasticsearch - Kibana将哪种持久性数据存储在path.data中?