elasticsearch 如何在ElasticSearch中从文件导入GEO_类型,elasticsearch,elasticsearch" /> elasticsearch 如何在ElasticSearch中从文件导入GEO_类型,elasticsearch,elasticsearch" />

elasticsearch 如何在ElasticSearch中从文件导入GEO_类型

elasticsearch 如何在ElasticSearch中从文件导入GEO_类型,elasticsearch,elasticsearch,使用下面的查询创建索引。弹性搜索正在windows上运行 curl -XPUT http://localhost:9200/us_large_cities -d "{"""mappings""": {"""city""": {"""properties""": {"""city""": {"""type""": """string"""},"""state""": {"""type""": """string"""},"""location""": {"""type""": """geo_po

使用下面的查询创建索引。弹性搜索正在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"
这给了我错误

'错误类型:非法\u参数\u异常'

'原因:操作/元数据行[1]格式错误,应为START\u对象或END\u对象,但为foung[值字符串]

我的文件数据是:

{“城市”:“伯明翰”,“州”:“阿尔”,“地点”:{“拉特”:“33.5206608”,“朗”:“-86.8024900”}

{“城市”:“亨茨维尔”,“州”:“阿尔”,“地点”:{“拉特”:“34.7303688”,“长”:“-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}}

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

{ "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}}

谢谢,先生,现在它给我的错误“文件必须是[lat]、[long]或[geohash]”…当我使用下面的格式时,它成功地插入了值。{“索引”:{“索引”:“美国大城市”,“美国类型”:“城市”}{“城市”:“伯明翰”,“州”:“阿尔”,“位置”:[33.5206608,-86.8024900]}{“索引”:“美国大城市”,“美国类型”:“城市”}{“城市”:“移动”,“州”:“阿尔”,“位置”:[30.6943566,-88.0430541]}想知道你们的解决方案有什么问题吗?为什么它会给我们例外。在你们给我的样本中,lat和long是作为字符串给出的。它应该是一样长的。谢谢,先生,现在它给我的错误是“field必须是[lat]、[long]或[geohash]”。当我使用下面的格式时,它成功地插入了值。{“索引”:{“索引”:“美国大城市”,“美国类型”:“城市”}{“城市”:“伯明翰”,“州”:“阿尔”,“位置”:[33.5206608,-86.8024900]}{“索引”:“美国大城市”,“美国类型”:“城市”}{“城市”:“移动”,“州”:“阿尔”,“位置”:[30.6943566,-88.0430541]}想知道你们的解决方案有什么问题吗?为什么它会给我们例外。在你们给我的样本中,lat和long是作为字符串给出的。它应该一样长。