Covariant type search in NEST v6.x and Elasticsearch v6.x

Hi,
We're trying to upgrade our cluster from v5 to v6 - doing so we're also upgrading to v6 for our NEST/Elasticsearch.net libraries.
Since types are now removed (or will be removed in v7) - I'm trying to use the TypeNameHandling.All option to include $type when serializing so it knows what to deserialize to when using multiple indices in our search queries. I got it to work by injecting a custom serializer in the connection settings.

But now I'm running into trouble with NEST objects which also includes the $type variable, for example, lat/lon coordinates - which uses a geo point field. Elasticsearch doesn't understand the $type when indexing:

{"$type":"Utilities.Elastic.Models.ElasticModels+CoordinatesData, Utilities","lat":0.0,"lon":0.0}}

 {
  "index": {
    "_index": "index-name",
    "_type": "item",
    "_id": "565",
    "status": 400,
    "error": {
      "type": "mapper_parsing_exception",
      "reason": "failed to parse",
      "caused_by": {
        "type": "parse_exception",
        "reason": "field must be either [lat], [lon] or [geohash]"
      }
    }
  }
}

Is there a way to make NEST behave, maybe only including the TypeNameHandeling on the root object, or is there another way to handle covariant searches in NEST v6.x?

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.