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

**URL:** <https://discuss.elastic.co/t/covariant-type-search-in-nest-v6-x-and-elasticsearch-v6-x/130355>\
**Category:** Elasticsearch\
**Created:** [May 3, 2018, 3:42am UTC](https://discuss.elastic.co/t/covariant-type-search-in-nest-v6-x-and-elasticsearch-v6-x/130355 "2018-05-03T03:42:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nmartins](https://avatars.discourse-cdn.com/v4/letter/n/b3f665/32.png) [@nmartins](https://discuss.elastic.co/u/nmartins)\
**Post date:** [May 3, 2018, 3:42am UTC](https://discuss.elastic.co/t/covariant-type-search-in-nest-v6-x-and-elasticsearch-v6-x/130355/1 "2018-05-03T03:42:10Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 31, 2018, 3:42am UTC](https://discuss.elastic.co/t/covariant-type-search-in-nest-v6-x-and-elasticsearch-v6-x/130355/2 "2018-05-31T03:42:13Z")

</div>

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