Im having a problem mapping "Geo Point" in elasticsearch using NEST C# Client.
Here is my class definition:
[GeoPoint(Name = "coordinates", LatLon = true)]
public Coordinates Coordinates { get; set; }
public class Coordinates
{
[Number(NumberType.Double, Name = "lat")]
public double Lat { get; set; }
[Number(NumberType.Double, Name = "lng")]
public double Lng { get; set; }
}
My mapping properties on Index creation:
.Mappings(map => map
.Map<Crime>(m => m.AutoMap()
.TimestampField(ts => ts.Enabled(true).Path("timeStamp"))
.Properties(pro => pro
.GeoPoint(geo => geo
.Name(n => n.Coordinates)
.LatLon(true)
))))
And my mapping doesnt look right once some documents were indexed....
...
"coordinates": {
"properties": {
"lat": {
"type": "double"
},
"lng": {
"type": "double"
}
}
},
...
And when i try querying it (using SENSE) I get the following error:
"reason": {
"type": "query_parsing_exception",
"reason": "failed to parse [geo_bbox] query. could not find [geo_point] field [coordinates]",
"index": "someindexname",
"line": 16,
"col": 9
}
So in my opinion the problem is with my mapping, but everything has changed quite drastically in 2.x update (compared to 1.x) that I dont know how to map a geo point properly. Any Ideas ?
Solved - updated NEST library to the newest release -
And also renamed my Coordinates class member Lng to Lon:
[Number(NumberType.Double, Name = "lon")]
public double Lon { get; set; }
I think the C# declaration doesnt matter its just the annotation thats important.
Thanks
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.