# Crud opearation is not working in Elasticsearch nest 5.0

**URL:** <https://discuss.elastic.co/t/crud-opearation-is-not-working-in-elasticsearch-nest-5-0/73316>\
**Category:** Elasticsearch\
**Created:** [January 31, 2017, 6:05am UTC](https://discuss.elastic.co/t/crud-opearation-is-not-working-in-elasticsearch-nest-5-0/73316 "2017-01-31T06:05:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrutyunjaya](https://avatars.discourse-cdn.com/v4/letter/m/e274bd/32.png) [@mrutyunjaya](https://discuss.elastic.co/u/mrutyunjaya)\
**Post date:** [January 31, 2017, 6:05am UTC](https://discuss.elastic.co/t/crud-opearation-is-not-working-in-elasticsearch-nest-5-0/73316/1 "2017-01-31T06:05:16Z")

</div>

public class Animal  
{  
public const string SearchIndex = "animals";  
public int Id { get; set; }  
public string AnimalType { get; set; }  
public string TypeSpecificForAnimalType { get; set; }  
public string Description { get; set; }  
public string Gender { get; set; }  
public string LastLocation { get; set; }

```
}
private void ValidateIfIdIsAlreadyUsedForIndex(string id)
	{
		var idsList = new List<string> { id };
		var result = _elasticsearchClient.Search<Animal>(s => s
			.Index("animals")
			.AllTypes()
			.Query(p => p.Ids(idsList)));
		if (result.Documents.Any()) throw new ArgumentException("Id already exists in store");
	}

```

I am using nest version 5.0.0.0 and error i am getting  
cannot convert from 'System.Collections.Generic.List' to 'System.Func\<Nest.IdsQueryDescriptor,Nest.IIdsQuery\>'

---

<div class="post-metadata">

**Author:** ![KodrAus](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kodraus/32/22798_2.png) [@KodrAus](https://discuss.elastic.co/u/KodrAus)\
**Post date:** [January 31, 2017, 6:52am UTC](https://discuss.elastic.co/t/crud-opearation-is-not-working-in-elasticsearch-nest-5-0/73316/2 "2017-01-31T06:52:41Z")

</div>

That's because the `.Ids` method takes a lambda function instead of just a list of ids. You can get the same behaviour by calling:

```auto
.Query(p => p.Ids(ids => ids.Values(id)))

```

Note that `.Values` takes a `params string[]`, so you don't need `idsList`, you can just pass your one `id` parameter straight in.

---

<div class="post-metadata">

**Author:** ![mrutyunjaya](https://avatars.discourse-cdn.com/v4/letter/m/e274bd/32.png) [@mrutyunjaya](https://discuss.elastic.co/u/mrutyunjaya)\
**Post date:** [January 31, 2017, 7:21am UTC](https://discuss.elastic.co/t/crud-opearation-is-not-working-in-elasticsearch-nest-5-0/73316/3 "2017-01-31T07:21:54Z")

</div>

Thanks , But this previous code is working in nest 1.0.0.0

---

<div class="post-metadata">

**Author:** ![KodrAus](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kodraus/32/22798_2.png) [@KodrAus](https://discuss.elastic.co/u/KodrAus)\
**Post date:** [January 31, 2017, 8:57pm UTC](https://discuss.elastic.co/t/crud-opearation-is-not-working-in-elasticsearch-nest-5-0/73316/4 "2017-01-31T20:57:39Z")

</div>

The API for NEST must have changed at some point. There were big changes between `1.x` and `2.x` so it might have been around then. I haven't really used `ids` queries so I'm not sure 🙂

---

<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:** [February 28, 2017, 8:57pm UTC](https://discuss.elastic.co/t/crud-opearation-is-not-working-in-elasticsearch-nest-5-0/73316/5 "2017-02-28T20:57:49Z")

</div>

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