predicate.notAny or equivalent

Hi, we have a bunch of content which is fully tagged. What I would like to do is use the predicate.not('document.tags', [excludeTags]) query to exclude documents returned which contain any of those tags.

Is that possible? It seems like it should work by default? But it seems like it's expecting the entire tag list to not match (and I don't know the entire tag list)

Hi @latchaid ,

Welcome to the community!

Yes, you can find the not predicate as explained here in our Rest API docs:

Indeed, but results are definitely returned that shouldn't be. For instance, If I have 2 predicates:

predicates.any('document.tags', [includeTags])
predicate.not('document.tags', [excludeTags])

It's like predicate.not is either:

  1. Overridden completely, even if there is no overlap of tags
  2. Only applies to documents where all tags in the excludeTags match, so only will exclude documents containing all of the excludeTags rather than at least 1.

So basically, question remains, is there a "notAny" type predicate? Or is my best bet to post process the data with my exclude list?...That will break things like pagination for example so it's a little bit awkward but may be doable

Your assumption here is correct. This is essentially the description in the documentation.

[not] Checks that the path doesn't match the provided value exactly.

There's no notAny predicate.

Correct, this is your best option here.

For anyone that stumbles onto this, a workaround for the functionality I requested, is to create a predicate.not for each tag you don't want included! For example:

predicate.not('document.tags', ['dontIncludeThisOne'])
predicate.not('document.tags', ['orThisOne'])
predicate.any('document.tags', ['includeThis', 'alsoThis'])

1 Like