Reputation: 1379
I am trying to delete the specific documents from ElasticSearch using DeleteByQuery(..) method but it does not work. The response i get shows 200 status.
I can get the results if i search same query.
Below is my query -
FilterContainer[] container = new FilterContainer[2];
FilterContainer TypeFilter = new TermFilter
{
Field = "TYPE",
Value = TableName
};
FilterContainer BRConnectionIDFilter = new TermFilter
{
Field = "BRCONNECTIONID",
Value = BRConnectionID
};
container[0] = TypeFilter;
container[1] = BRConnectionIDFilter;
IDeleteResponse response = objElasticNestClient.DeleteByQuery<dynamic>(s => s.Index(ExtractionContext.ElasticSearchIndex).Query(b => b.Filtered(q => q.Query(a => a.MatchAll()).Filter(f => f.Bool(m => m.Must(container))))));
if (!response.IsValid && response.ConnectionStatus.HttpStatusCode == 200)
{
throw new Exception("Delete failed for object " + TableName + ". Error: " + response.ServerError);
}
I have used INDEX as NOT_ANALYZED for all fields.
Can anyone please guide me on this?
Upvotes: 0
Views: 659
Reputation: 1379
It worked after replacing query like below -
IDeleteResponse response = objElasticNestClient.DeleteByQuery<dynamic>(s => s.Index(ExtractionContext.ElasticSearchIndex).Type(TableName).Query(b => b.Filtered(q => q.Query(a => a.MatchAll()).Filter(f => f.Term("BRCONNECTIONID", BRConnectionID)))));
if (!response.IsValid && response.ConnectionStatus.HttpStatusCode == 200)
{
throw new Exception("Delete failed for object " + TableName + ". Error: " + response.ServerError);
}
Upvotes: 0