The Match
function only performs a strict equivalence match: you can’t adjust it to perform some other kind of match.
Ideally, you could use the Difference
function to find the set of documents that does not match the indexed documents. For example:
q.map_(
q.lambda_("x", q.get(q.var("x"))),
q.paginate(
q.difference(
q.documents(q.collection("some_collection")),
q.match(q.index("my_index"),"blah")
)
)
)
That works reasonably well only for small collections. Large collections could cause your query to time out and never provide a result.
If you know the term ahead of time, you can create an index binding that can compute an indexable value however you like:
q.create_index({
name: "my_index2",
source: {
collection: q.collection("some_collection"),
fields: {
hasBlah: q.query(
q.lambda_(
"doc",
q.equals(q.select(["data", "field"], ""), "blah")
)
),
},
},
terms: [
{ binding: "hasBlah" }
],
})
With that index, you query would look like:
q.map_(
q.lambda_("x", q.get(q.var("x"))),
q.paginate(q.match(q.index("my_index2"), False))
)
If you don’t know the term ahead of time, you’ll effectively need to perform a full scan of the collection, issuing multiple queries to paginate through the entire set of documents, filter the pages (and dealing with potentially empty pages), composing the final result set.