Index simple data in (a custom) catalog

In my case I'm trying to index a memberdata property added to users:

from plone.indexer.decorator import indexer

def getCustomValue(obj):
    return obj.getProperty("custom_user_field")

The magic expected to happen here:

def catalog_rebuild(context):
    portal_catalog = api.portal.get_tool('portal_catalog')
    my_catalog = get_catalog()

    md = api.portal.get_tool("portal_memberdata")
    _members = md._members
    _properties = api.portal.get()[

    for idx, user_id in enumerate(_members.iterkeys()):
        print "{0}: {1}".format(idx, user_id)
        user_member_data = _members.get(user_id)
        user_properties = _properties.get(user_id, dict())

        if user_member_data is not None:
            values = user_properties.get('custom_user_field', [])

            if len(values) > 0:
                user = api.user.get(user_id)

The problem is memberdata is not an real indexable object (I think). My getCustomValue is created but no value is indexed.

So my question is: how to index any simple data in a (z)catalog? Let's say I have an json containing users and their preferred colors like:
'Alice': ['blue', 'red'],
'Bob': ['yellow', 'blue']
and for some reason I want to index these values in a catalog (KeywordIndex). In order to have queries like:
>>> my_catalog.searchResults(color="blue")
>>> ["Alice", "Bob"]

I found something here: (but contains broken link...)
Also on github (I use to search code...):

Is there any simple tutorial on this? Or can you provide an example?

In general: only persistent content objects are indexed by Plone. Member data is no content in the Plone sense.

Perhaps you want something like membrane?

1 Like

For simple data, you can also use which gives you simple data store and also supports indexing.

1 Like