简体   繁体   English

对Nest / ElasticSearch.Net使用普通的双纬度/经度属性

[英]Using plain double Latitude / Longitude Properties for Nest / ElasticSearch.Net

I am a tad confused when it comes to indexing my domain models that include plain Latitude / Longitude (both double properties) with Nest / ElasticSearch.Net: 对于使用Nest / ElasticSearch.Net索引包含普通纬度/经度(均为双重属性)的域模型,我有点困惑:

Is there a way to map those two POCO / double properties over & tell ElasticSearch.Net that these two are actually what they are, geolocation points and have them indexed accordingly without having to pull in a dependency of ElasticSearch.net and its GeoLocation type in the domain model assembly? 有没有一种方法可以将这两个POCO / double属性映射到&告诉ElasticSearch.Net它们实际上是它们的地理位置点,并对其进行相应索引,而不必在其中引入ElasticSearch.net及其GeoLocation类型的依赖项域模型装配?

I'd rather not do the later nor would I want to create separate 'search'-specific models. 我宁愿不做以后也不愿创建单独的“搜索”特定模型。

The geo_point type consists of both a latitude and longitude coordinate and supports a few different input formats : object (with lat lon properties), array, or a comma-delimited string. geo_point类型包含纬度和经度坐标,并支持几种不同的输入格式 :对象(具有lat lon属性),数组或逗号分隔的字符串。

You can't map two separate double fields as a single geo_point field. 您不能将两个单独的double字段映射为单个geo_point字段。 You'll have to add another field to your POCO and combine them using one of the supported formats. 您必须在POCO中添加另一个字段,并使用一种受支持的格式将其合并。

The object format however is ideal since there is no discrepancy on which value is lat and which is lon. 但是,对象格式是理想的,因为在哪个值是lat,哪个值是lon上没有差异。 If you want to keep your POCO clean of NEST dependencies, you can always roll your own geo type as long as it contains a Lat and Lon property, instead of using the baked in GeoLocation type. 如果您想使POCO摆脱NEST依赖关系,则可以始终滚动您自己的地理类型,只要它包含LatLon属性即可,而不是使用烘焙的GeoLocation类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM