Reputation: 565
I'm using Tridion.ContentDelivery.DynamicContent.Query. I'm trying to filter components and exclude some of them by the taxonomy keyword, my code:
List<Criteria> excludeCriteria = new List<Criteria>();
foreach (string keywordUri in excludeKeywords)
{
excludeCriteria.Add(new TaxonomyKeywordCriteria(categoryUri, keywordUri, false));
}
Criteria criteria = new NotInCriteria(new AndCriteria(excludeCriteria.ToArray())));
Query query = new Query(criteria);
The problem is, that in result I have a list that filtered only by one of TaxonomyKeywordCriteria. The first one criteria from excludeKeywords list are applied, and all others are ignored.
Upvotes: 3
Views: 448
Reputation: 4835
I'm not entirely sure, but I have a feeling when you add the Criteria like this you get a OR list somehow (you could check the debug log of the broker, that should have the query executed in there).
Can you try it the other way around, wrapping your TaxonomyKeywordCriteria in a NotInCriteria and adding those to the AndCriteria? So something like this:
List<Criteria> excludeCriteria = new List<Criteria>();
foreach (string keywordUri in excludeKeywords)
{
excludeCriteria.Add(new NotInCriteria(new TaxonomyKeywordCriteria(categoryUri, keywordUri, false)));
}
Criteria criteria = new AndCriteria(excludeCriteria.ToArray()));
Query query = new Query(criteria);
Upvotes: 2