# C# NEST ElasticSearch 2.3.4 client returns additional instances

**URL:** <https://discuss.elastic.co/t/c-nest-elasticsearch-2-3-4-client-returns-additional-instances/58385>\
**Category:** Elasticsearch\
**Created:** [August 18, 2016, 6:16pm UTC](https://discuss.elastic.co/t/c-nest-elasticsearch-2-3-4-client-returns-additional-instances/58385 "2016-08-18T18:16:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fpopic](https://avatars.discourse-cdn.com/v4/letter/f/3ab097/32.png) [@fpopic](https://discuss.elastic.co/u/fpopic)\
**Post date:** [August 18, 2016, 6:16pm UTC](https://discuss.elastic.co/t/c-nest-elasticsearch-2-3-4-client-returns-additional-instances/58385/1 "2016-08-18T18:16:26Z")

</div>

[http://stackoverflow.com/questions/39021236/c-sharp-nest-elasticsearch-2-3-4-client-returns-additional-instances](http://stackoverflow.com/questions/39021236/c-sharp-nest-elasticsearch-2-3-4-client-returns-additional-instances)

I have only one document in my ElasticSearch index with `Events_Id == 986147`

```
+---------+---------+---------+----------------+-------+---------+-------------+
|Animal_Id|EventName|Events_Id|Extras |Farm_Id|Farmer_Id|Time |
+---------+---------+---------+----------------+-------+---------+-------------+
|126248 |Abortion |986147 |[null,null,null]|5095 |-1 |1419634800000|
+---------+---------+---------+----------------+-------+---------+-------------+

```

but when I execute in C#:

```
 var r1 = client.Search<Nesting>(new 
 {
        Query = new TermQuery {Field = "Events_Id", Value = "986147"}
 });

```

I got 3x instances  
where first two don't exist in ES (they have totaly new value for parameter Time):

```
Nesting(Events_Id:986147, Animal_Id:126248, Farm_Id:5095, Time:1420473746707, EventName:Abortion, Farmer_Id:-1, Extras:)
Nesting(Events_Id:986147, Animal_Id:126248, Farm_Id:5095, Time:1420473746707, EventName:Abortion, Farmer_Id:-1, Extras:)

Nesting(Events_Id:986147, Animal_Id:126248, Farm_Id:5095, Time:1419634800000, EventName:Abortion, Farmer_Id:-1, Extras:From_Stall_Id:, To_Stall_Id:, HoldingPen_Id:)

```

My schema looks like:

```
root
 |-- Animal_Id: long (nullable = true)
 |-- EventName: string (nullable = true)
 |-- Events_Id: long (nullable = true)
 |-- Extras: struct (nullable = true)
 | |-- From_Stall_Id: long (nullable = true)
 | |-- HoldingPen_Id: long (nullable = true)
 | |-- To_Stall_Id: long (nullable = true)
 |-- Farm_Id: long (nullable = true)
 |-- Farmer_Id: long (nullable = true)
 |-- Time: long (nullable = true)

```

and C# classes:

```
class NestedExtras
{
	long? From_Stall_Id { get; set; }
	long? To_Stall_Id { get; set; }
	long? HoldingPen_Id { get; set; }
}

class Nesting
{
	long? Events_Id { get; set; }
	long? Animal_Id { get; set; }
	long? Farm_Id { get; set; }

	long? Time { get; set; }

	string EventName { get; set; }
	long? Farmer_Id { get; set; }
	NestedExtras Extras { get; set; }
}

```

I have tested with HTTP-API and SPARK-ES and they return only one document so I must be something missing about C#/NEST nullable or something like that?

---

<div class="post-metadata">

**Author:** ![fpopic](https://avatars.discourse-cdn.com/v4/letter/f/3ab097/32.png) [@fpopic](https://discuss.elastic.co/u/fpopic)\
**Post date:** [August 18, 2016, 6:37pm UTC](https://discuss.elastic.co/t/c-nest-elasticsearch-2-3-4-client-returns-additional-instances/58385/2 "2016-08-18T18:37:29Z")

</div>

I didn't specify exact index/type so NEST searched for all indexes for specified type:

```
 var client = new ElasticClient(new ConnectionSettings(
        new Uri("http://localhost:9200"))
      .DefaultIndex("xfarm")
      .DefaultTypeNameInferrer(type => "activity_log")
  );
```

---

<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:** [July 5, 2017, 10:24pm UTC](https://discuss.elastic.co/t/c-nest-elasticsearch-2-3-4-client-returns-additional-instances/58385/3 "2017-07-05T22:24:42Z")

</div>


