Location Mapping in Elasticsearch 7.6

Hello,

I need help to get the location mapping for my dataset.
I have the longitude and latitude and I tried to follow the official documentation about "geo-point datatype", but it doesn't work.

Here is the logstash file:

input {
	file {
		path => "C:/elastic_stack/new-york-city-airbnb-open-data/*.csv"
		start_position => "beginning"
		sincedb_path => "nul"
	}
}
filter {
	csv {
		separator => ","
		columns => ["id","name","host_id","host_name","neighbourhood_group","neighbourhood","latitude","longitude","room_type","price","minimum_nights","number_of_reviews","last_review","reviews_per_month","calculated_host_listings_count","availability_365"]
	}
	mutate { convert => {"latitude" => "float"} }
	mutate { convert => {"longitude" => "float"} }
	mutate { rename => {"latitude" => "[location][lat]"} }
	mutate { rename => {"longitude" => "[location][lon]"} }
}
output {
	elasticsearch {
		hosts => "http://localhost:9200"
		index => "nyc_test_2019"
		document_type => "nyc_test_2019"
	}
}

I have also put the mapping before uploading the data:

PUT nyc_test_2019
{
  "mappings": {
    "properties": {
      "location": {
        "type": "geo_point"
      }
    }
  }
}

But the data will not be uploaded if I define the geo_point before.

WARN from Logstash:

[2020-02-16T19:37:17,578][WARN ][logstash.outputs.elasticsearch][main] Could not index event to Elasticsearch. {:status=>400, :action=>["index", {:_id=>nil, :_index=>"nyc_test_2019", :routing=>nil, :_type=>"nyc_test_2019"}, #LogStash::Event:0x3d93f3af], :response=>{"index"=>{"_index"=>"nyc_test_2019", "_type"=>"nyc_test_2019", "_id"=>"QsRJT3AB8aRVYGwY8OQi", "status"=>400, "error"=>{"type"=>"illegal_argument_exception", "reason"=>"Rejecting mapping update to [nyc_test_2019] as the final mapping would have more than 1 type: [_doc, nyc_test_2019]"}}}}
[2020-02-16T19:37:17,641][WARN ][logstash.filters.csv ][main] Error parsing csv {:field=>"message", :source=>"3757461,"Manhattan Sun Drenched ", :exception=>#<CSV::MalformedCSVError: Unclosed quoted field on line 1.>}
[2020-02-16T19:37:17,647][WARN ][logstash.filters.csv ][main] Error parsing csv {:field=>"message", :source=>"Near Gramercy",17465563,Lola,Manhattan,Gramercy,40.73601,-73.98205,Private room,69,2,177,2019-06-22,2.98,1,285", :exception=>#<CSV::MalformedCSVError: Illegal quoting in line 1.>}

WARN from Elasticsearch:

[2020-02-16T19:38:01,710][DEBUG][o.e.a.a.i.m.p.TransportPutMappingAction] [DESKTOP-192PII9] failed to put mappings on indices [[[nyc_test_2019/_5fqjPKPRTOFDqEWDdEu7g]]], type [nyc_test_2019]
java.lang.IllegalArgumentException: Rejecting mapping update to [nyc_test_2019] as the final mapping would have more than 1 type: [_doc, nyc_test_2019]
at org.elasticsearch.cluster.metadata.MetaDataMappingService$PutMappingExecutor.applyRequest(MetaDataMappingService.java:272) ~[elasticsearch-7.5.2.jar:7.5.2]
at org.elasticsearch.cluster.metadata.MetaDataMappingService$PutMappingExecutor.execute(MetaDataMappingService.java:238) ~[elasticsearch-7.5.2.jar:7.5.2]
at org.elasticsearch.cluster.service.MasterService.executeTasks(MasterService.java:702) ~[elasticsearch-7.5.2.jar:7.5.2]
at org.elasticsearch.cluster.service.MasterService.calculateTaskOutputs(MasterService.java:324) ~[elasticsearch-7.5.2.jar:7.5.2]
at org.elasticsearch.cluster.service.MasterService.runTasks(MasterService.java:219) [elasticsearch-7.5.2.jar:7.5.2]
at org.elasticsearch.cluster.service.MasterService.access$000(MasterService.java:73) [elasticsearch-7.5.2.jar:7.5.2]
at org.elasticsearch.cluster.service.MasterService$Batcher.run(MasterService.java:151) [elasticsearch-7.5.2.jar:7.5.2]
at org.elasticsearch.cluster.service.TaskBatcher.runIfNotProcessed(TaskBatcher.java:150) [elasticsearch-7.5.2.jar:7.5.2]
at org.elasticsearch.cluster.service.TaskBatcher$BatchedTask.run(TaskBatcher.java:188) [elasticsearch-7.5.2.jar:7.5.2]
at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:703) [elasticsearch-7.5.2.jar:7.5.2]
at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.runAndClean(PrioritizedEsThreadPoolExecutor.java:252) [elasticsearch-7.5.2.jar:7.5.2]
at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(PrioritizedEsThreadPoolExecutor.java:215) [elasticsearch-7.5.2.jar:7.5.2]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
at java.lang.Thread.run(Thread.java:830) [?:?]

I hope you can help me. I've been trying for more than a week now.

Best regards,
André

Change

document_type => "nyc_test_2019"

With

document_type => "_doc"
1 Like

Thank you very much!

I´t works perfect.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.