Hi,
I'm using the following mapping(Node.Js):
function initMapping() {
return elasticClient.indices.putMapping({
index: indexName,
type: "marker",
body: {
properties: {
name: { type: "string" },
location: { type: "geo_point" },
}
}
});
}
Inserting looks like (using Sense):
PUT /randomindex/marker/7
{
"name": "hooooo",
"location": {
"lat": 40.722,
"lon": -73.989
}
}
Searching looks like:
GET /randomindex/marker/_search
{
"query": {
"filtered" : {
"filter": {
"geo_distance": {
"distance": "1000km",
"location":{
"lat":40.722,
"lon":-73.989
}
}
}
}
}
}
by doing this I'm getting the following error: "failed to find geo_point field [location]"
what Am I doing wrong?
Thanks!!
Hi @shaykeren,
I guess you are using Elasticsearch 1.7.
I tried the following with Elasticsearch 1.7.1 in Sense and it works as expected for me:
PUT randomindex
{
"mappings": {
"marker": {
"properties": {
"name": {
"type": "string"
},
"location": {
"type": "geo_point"
}
}
}
}
}
PUT /randomindex/marker/7
{
"name": "hooooo",
"location": {
"lat": 40.722,
"lon": -73.989
}
}
GET /randomindex/marker/_search
{
"query": {
"filtered": {
"filter": {
"geo_distance": {
"distance": "1000km",
"location": {
"lat": 40.722,
"lon": -73.989
}
}
}
}
}
}
- Is the mapping as you'd expect it? Check this with
GET /randomindex/_mapping
- Is the document actually inserted? Check this with
GET /randomindex/marker/7
- Maybe you have also a very high refresh_interval? For testing purposes you can issue
POST /randomindex/_refresh
after you have inserted the document. If it is found now, you should probably decrease your refresh interval.
I hope this hints help you.
Daniel