WebHare community

How does CQNot work?

I can’t make any sense of CQNot.

I have two items in my index:

+PROCESSID: 104656
+PROCESSID: 104659

In a query like this:

INSERT CQMatch("processid", "=", "104656") INTO query_and AT END;

I’m getting the expected process (104656).

However, if I turn the CQMatch around (well, that’s what I’m expecting anyway):

INSERT CQNot(CQMatch("processid", "=", 104656)) INTO query_and AT END;

I expect the other result (104659), but now the query doesn’t return anything.

Am I misinterpreting the CQNot function?

CQNot cannot be the only clause in a query, it can only be used to limit a result set from another query by combining it using CQAnd. From your code snippets it isn’t clear if the CQNot is the only clause in your query, or if you’re already combining it with other queries (i.e. if the CQNot clause is the only one in the query_and array or not).

If you’re already combining it, make sure the other item is returned if you explicitly search for it using CQMatch or CQHas("processid").

If you don’t have any other clauses, you can combine it with CQHas("processid") or CQAll, for example:

CQAnd([ CQHas("processid"), CQNot(CQMatch("processid", "=", "104656")) ])

Alright, excellent info, thanks!