I'm using NodeJS ElasticSearch with ElasticSearch 7.0. I create mapping geo_point
type on specific field, but it doesn't show geo_point type in _mapping
. I tried to search using filter.geo_distance
, I got failed to find geo point field
.
Node ElasticSearch Mapping
client.indices.putMapping({
index: 'listing',
type: 'detail',
body: {
properties: {
'listing_coordinates': {
"type": "geo_point"
}
}
}
}, function(err) { console.log(err) })
Mapping Error
[illegal_argument_exception] Types cannot be provided in put mapping requests, unless the include_type_name parameter is set to true.
/listing/_mapping
mappings: {
properties: {
"listing_coordinates": {
"properties": {
"lat": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"lon": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
},
}
}
Node Search
client.search({
index: 'listing',
type: 'detail',
size: 5,
body: {
query : {
"bool": {
"filter": {
"geo_distance" : {
"distance" : "500km",
"listing_coordinates" : {
"lat" : 3.0567521,
"lon" : 101.5854671
}
}
}
}
}
}
}
Search error
[query_shard_exception] failed to find geo_point field [listing_coordinates]
I had mapping dates fields on my listing, it worked well.