Try our conversational search powered by Generative AI!

Delete an index object which attribute contains a given value


There's an index object which is having an attribute of type List and I need to delete the index object, when that attribute contains a given value. 

I tried this,

SearchClient.Instance.Delete(x => x.RelatedEntities.Contains(given_id));

But it says, "Can not convert expression type 'bool' to return type 'EPiServer.Find.Api.Quering.Filter'"

Is there a simple way to do this straight away? 

Jul 03, 2015 11:32

Could you try to use Match extension method instead of Contains? Like this:

SearchClient.Instance.Delete<NewsFeedItem>(x => x.RelatedEntities.Match(given_id));
Jul 03, 2015 14:14

Thanks for the reply. Please help with this.

How can we update (instead delete) an instance of the index in the same scenario like above? 

Jul 13, 2015 12:12

There are two ways you could update the item.

The first way is to simply reindex the item:

            myItem.PageName = "A new name";

or, you could update the field directly if you have the ID:

SearchClient.Instance.Update<PageData>(4).Field(x => x.PageName, "New page name").Execute();

Jul 13, 2015 13:22
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.