Indexing an unlabelled / dynamically linked document using geoinformation in the elasticearch NEST client

This is my first question on this site, so I will try to ask the question correctly.

while working with the elasticsearch socket client, I use volume indexing to store my data. All data can be indexed using Dictionary<string, object> . The company I'm working on insists on dynamic matching, which means I'm not allowed to declare variables that go to nodes.

 Dictionary <string, object> document_value= new Dictionary<string, object>(); Bulkcontainer.Index<object>(i => i.Index(index_name).Type(_type).Id(_id).Document(document_value)); 

This was not a problem before using GEO points. if these arent indexed as geo-integrations, they will not be searchable when they are placed in the subheading, they will by default contain a string. I cannot redefine them. data for geo-integration is given to the code in the form of another dictator, called geo-fields.

 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); } } } 

any help to clear my problem would be appreciated


i changed the index type to

 public class ES_DATA_GEO { public Dictionary<string, object> Data { get; set; } [ElasticProperty(Type = Nest.FieldType.GeoShape)] public GeoShape Locatiecoord { get; set; } } 

but now when I execute the request, it still does not register Locatiecoord as a Geo field

 Failed to find geo_shape field [locatiecoord]]; 

again any help is appreciated

+6
source share
2 answers

According to documents, geo-points cannot be automatically detected using dynamic matching. See Geo Definition

+2
source

If you create your index as follows:

 var created = client.CreateIndex("MyIndexName", c => c.AddMapping<dynamic>(m => m.Type("_default_"). DynamicTemplates(t => t.Add(f => f.Name("shape_fields") .Match("MyShapeFieldName").Mapping(ma => ma.GeoPoint(s => s.IndexGeoHash().IndexLatLon())))) 

Then your initial approach to indexing the dictionary will directly work if you have an entry in your dictionary with the key "MyShapeFieldName", which has the value Coordinate. You can probably change your pattern to match by type (Coordinator) rather than by name ("MyShapeFieldName"), but I have not tested it.

0
source

Source: https://habr.com/ru/post/986954/


All Articles