[英]Scan and Scroll Substitute in ElasticSearch version 2.x (NEST C#)
[英]ElasticSearch 2.x GeoPoint mapping with NEST C#
我在使用NEST C#Client在elasticsearch中映射“Geo Point”时遇到问题。
这是我的班级定义:
[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; }
}
我在索引创建时的映射属性:
.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)
))))
一旦某些文档被编入索引,我的映射看起来并不正确....
...
"coordinates": {
"properties": {
"lat": {
"type": "double"
},
"lng": {
"type": "double"
}
}
},
...
当我尝试查询它(使用SENSE)时,我收到以下错误:
"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
}
所以在我看来问题是我的映射,但是2.x更新(与1.x相比)的所有内容都发生了巨大的变化,我不知道如何正确映射地理点。 有任何想法吗 ?
解决 - 更新NEST库到最新版本 -
并且还将我的Coordinates类成员Lng重命名为Lon:
[Number(NumberType.Double, Name = "lon")]
public double Lon { get; set; }
我认为C#声明并不重要,只是注释很重要。
谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.