• Home
  • Popular
  • Login
  • Signup
  • Cookie
  • Terms of Service
  • Privacy Policy
avatar

Posted by User Bot


28 Nov, 2024

Updated at 12 Dec, 2024

New .Net client fails to synchronise GeoLocation as geo_point in index

Hi all,

We are currently in the process of migrating away from NEST given the new .Net Client seems to be the way to go going forwards however, the whole process has been nothing but painful so far.

The examples and documentation on the website are very lacking for the new .Net client and only amount to a getting started with no detailed breakdown of available fields and mappings for things like GeoLocation or indeed the deprication of old field types that used to be available in NEST and their new .Net client equivalent.

We have a large collection of objects we are looking to index. Previously we used to the annotations on our .Net class to indicate how each field should be mapped when the index is created but these have now been deprecated as part of the new .Net client. For most fields, the default mappings appear to be correct however, when we use the GeoLocation type provided in the .Net client nugget package in our .net class and map the relevant properties to it, when it get index into Elasticsearch it's not being mapped as a geo_point and is instead mapping the lat and long properties as two double/numeric values.

Can somebody shed some light on why this is the case and why the type provided by the Elastic client library is not mapping to the correct field type? I would have assumed a type provided by the library would have all the correct mappings automatically setup but that appears to not be the case when we view the indexes in Kibana.

We've also tried mapping the fields explicitly after the fact in two ways.

  • Create the index
  • Update the relevant fields to geo_point mapping
  • Index the fields

However this results in our objects not being indexed at all. Or

  • Indexing our objects directly to a non-existent index which creates the index with the documents but all the field mappings are wrong despite using the GeoLocation type.
  • Attempting to retrospectively alter the mappings to apply the geo_point property

The code below is how we are currently trying to achieve this using the .net client

    await _elasticsearchClient.IndexManyAsync<VenueResult>(data, finalIndexName);

            await _elasticsearchClient.Indices.PutMappingAsync<VenueResult>(mappings => mappings
                .Indices(finalIndexName)
                .Properties(properties => properties
                    .GeoPoint("location.coordinate")
                )

Could anyone shed some light on how this should be achieved using the new client? Alternatively, is there some hidden documentation on this I can be directed towards given none of this is mentioned in the documentation? We have a lot of logic on our site that utilises geolocation searches and finding places nearby so getting this to map correctly so we can utilise Elastic's strengths in geosearches is a critical implementation point for us.

2 posts - 2 participants

Read full topic