【发布时间】:2015-07-21 16:44:50
【问题描述】:
这是我在这个网站上的第一个问题,所以我会尝试正确地提出问题。
在使用 elasticsearch nest 客户端时,我使用批量索引来存储我的数据。所有数据都可以在Dictionary<string, object> 的帮助下进行索引。
我工作的公司坚持动态映射,这意味着我不能声明去节点的变量。
Dictionary <string, object> document_value= new Dictionary<string, object>();
Bulkcontainer.Index<object>(i => i.Index(index_name).Type(_type).Id(_id).Document(document_value));
在使用 GEO 点之前,这不是问题。 如果这些不是作为地理点索引的,它们将不可搜索,当放置在字典中时,它们将默认为字符串。我无法覆盖它们。 地理点的数据以另一个名为 geofields 的字典的形式提供给代码。
PointGeoShape coord = new PointGeoShape();
Dictionary<string, PointGeoShape> geovalue = new Dictionary<string, PointGeoShape>();
if (geofields!= null)
{
foreach (KeyValuePair<string, object> geo in geofields)
{
string veldnaam = geo.Key.ToUpper();
string temp = geo.Value.ToString();
if (temp != "")
{
string[] array = temp.Split(new char[] { ',' }, 2);
List<double> list = new List<double>();
list.Add(double.Parse(array[0]));//lon
list.Add(double.Parse(array[1]));//lat
IEnumerable<double> latlon = list;
coord.Coordinates = latlon;
document_value.Add(veldnaam, coord);
}
}
}
任何澄清我的问题的帮助将不胜感激
我将索引类型更改为
public class ES_DATA_GEO
{
public Dictionary<string, object> Data { get; set; }
[ElasticProperty(Type = Nest.FieldType.GeoShape)]
public GeoShape Locatiecoord { get; set; }
}
但现在当我执行查询时,它仍然没有将 Locatiecoord 注册为地理字段
Failed to find geo_shape field [locatiecoord]];
再次感谢任何帮助
【问题讨论】:
-
嗨,罗伊,我有一个类似的,如果你已经解决了,请告诉我,我已经把我的问题放在这里了。 stackoverflow.com/questions/33579086/…
-
嗨@Roy!你最后解决了吗?如果是,如何?谢谢!
-
嗨,弗洛林,已经好几年了,但从未找到解决此问题的方法。
标签: c# elasticsearch nest