Delete an index object which attribute contains a given value

Vote:
 

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? 

#123424
Jul 03, 2015 11:32
Vote:
 

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

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

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? 

#123647
Jul 13, 2015 12:12
Vote:
 

There are two ways you could update the item.

The first way is to simply reindex the item:

            myItem.PageName = "A new name";
            SearchClient.Instance.Index(myItem);

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();



#123649
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.