Is there a "not none" filter for a ZCTextIndex in ZCatalogs?

One of my old searches used TextIndexNG3 and the search query looked like

searchResults(
    hyId='not none',
    sort_on="sort_name",
    sort_order="ascending")

This worked.

I am about migrating all obsolete TextIndexNG3 indexes to ZCTextIndex - and all tests pass - except the one with above query.

self = <Products.ZCTextIndex.QueryParser.QueryParser instance at 0x7f0f7b2433f8>, tokentype = 'ATOM'

    def _require(self, tokentype):
        if not self._check(tokentype):
            t = self._tokens[self._index]
            msg = "Token %r required, %r found" % (tokentype, t)
>           raise ParseTree.ParseError, msg
E           ParseError: Token 'ATOM' required, u'not' found

../../../../../../../_/home/jugmac00/.batou-shared-eggs/Products.ZCTextIndex-2.13.5-py2.7-linux-x86_64.egg/Products/ZCTextIndex/QueryParser.py:156: ParseError

Do I have to instantiate all objects and ask the objects whether there is anything set for hyId or is there something to directly ask the catalog?

tl/dr
Which query do I have to build to get all results for objects which have anything set for a certain attribute?

AFAIK: ZCTextIndex does not support NOT as operator.

1 Like

Thank you - you brought me on the right track.

The none in the query is actually a string and not something which gets magically converted to a None/False/empty value.

For now, as this query gets very rarely used, and for each result a API call is made (which takes a bit), I created a generator for all results, which yields one object at a time. Good enough for now.

Hm, I guess another solution would be to create a helper function, which checks the value of the attribute and create a BooleanIndex for it (the helper function).

Plone Foundation Code of Conduct