Roy*_*Roy 6 c# elasticsearch nest
这是我在这个网站上的第一个问题,所以我会试着提出正确的问题.
在使用elasticsearch nest客户端时,我使用批量索引来存储我的数据.所有数据都可以在a的帮助下编制索引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));
Run Code Online (Sandbox Code Playgroud)
在使用GEO点之前,这不是问题.如果它们没有被编入索引作为地理点,它们将无法搜索,当放置在dictonary时它们将默认为字符串.我无法覆盖它们.geopoint的数据以另一个名为geofields的dictonary形式提供给代码.
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);
}
}
}
Run Code Online (Sandbox Code Playgroud)
任何帮助澄清我的问题将不胜感激
我将索引类型更改为
public class ES_DATA_GEO
{
public Dictionary<string, object> Data { get; set; }
[ElasticProperty(Type = Nest.FieldType.GeoShape)]
public GeoShape Locatiecoord { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
但是现在当我执行查询时,它仍然没有将Locatiecoord注册为Geo字段
Failed to find geo_shape field [locatiecoord]];
Run Code Online (Sandbox Code Playgroud)
再次感谢任何帮助
| 归档时间: |
|
| 查看次数: |
654 次 |
| 最近记录: |