I have a site running Plone 4.1 which has a custom content type developed with Dexterity 1.1. My content authors can add keywords to basic Plone pages using the Categorization tab and users successfully find these pages if they search using one of the keywords.
My content authors have also produced pages using a Dexterity custom content type I developed. This was defined using a Python-based file system schema. If users search for terms in the title and description of a Dexterity content type they get back the Dexterity pages in the search results. If they search using a query term in the keywords field they get no results. However, under the Advanced search form they can find the Dexterity page if they highlight the appropriate tag in the list of tags.
I've inspected the contents of the search index using the portal_catalog tool in ZMI. It appears keywords are being added to the SearchableText field for basic content types such as Page but for my Dexterity-based custom content type they are not.
Do I need to write additional code to insert the contents of the keywords field into the SearchableText index?
Let's say your Dexterity content type implements IFoo, and the keywords attribute defined in your schema is a list of strings.
You define your indexer in this way:
from five import grok
from plone.indexer.decorator import indexer
from my.dexteritycontent.foo import IFoo
@indexer(IFoo)
def searchableIndexer(context):
keywords = " ".join(context.keywords)
return "%s %s %s" % (context.title, context.description, keywords)
grok.global_adapter(searchableIndexer, name="SearchableText")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With