【发布时间】:2025-11-26 03:30:01
【问题描述】:
使用以下查询创建索引。 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'
'原因:动作/元数据行 [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"}}
{"city": "Mobile", "state": "AL","location": {"lat" : "30.6943566", "long" : "-88.0430541"}}
【问题讨论】:
标签: elasticsearch