All questions

Getting "Too complex query" on a long audience expression

Asked by Sanjay Iyer on

SISanjay Iyer

We evaluate a condition covering a few dozen category landing pages, basically a long chain of page's path is "/x" or page's path is "/y" or ... built by string concatenation. It worked at around 20 paths, then started throwing "Too complex query" as the catalog grew.

What is the actual limit here? Is it character count, expression depth, or something else? And is there a recommended pattern for large conditions like this, since our category list will keep growing.

Was this helpful?

1 answer

AVAnouk VerhoevenAccepted answer

Evaluation API queries are limited to 1-500 UTF-8 characters, and oversized or overly nested expressions return exactly that error. A few dozen or-chained path comparisons blows through 500 characters easily, which lines up with when it started failing for you.

The fix is usually structural rather than a bigger limit:

page's path is in ["/home", "/about", "/pricing"]

An is in list carries one comparison's worth of syntax overhead no matter how many values it holds, so it compresses dramatically compared to or-chains. For repeated fragments, let variables help too:

let prefix = "/categories/";page's path matches prefix

If the category list keeps growing beyond what fits in 500 characters, that is a signal to match on a shared path prefix or attribute instead of enumerating pages.

Also wrap client-side calls defensively:

croct.evaluate(query).catch(() => false)

so any evaluation failure degrades to default content instead of breaking the page.

Was this helpful?
Still have questions?