Catalog
The Catalog Tool is the tool that Plone uses for indexing and searching content. Check the Indexing and Searching section of the Developer Manual for more information about how the Catalog Tool works.
Imagine you've created an 'Apartment' content-type using Archetypes with a field called 'address'. To index the address of each apartment so to be able to search by this field, create a catalog_tool.xml file in your extension profile with the following content:
<?xml version="1.0"?> <object name="portal_catalog" meta_type="Plone Catalog Tool"> <index name="address" meta_type="FieldIndex"> <indexed_attr value="getAddress" /> </index> <column value="a_field" /> </object>
The first line after the xml declaration specifies the type of object GenericSetup is dealing with: the Plone Catalog Tool, with id portal_catalog.
The 'index' node will create a new index of the type 'meta_type' with the name specified. You can find a list of the available meta-types, as well as the differences between them in the Searching and Categorizing Content section of The Zope Book.
The 'indexed_attr' node specifies the name of the attribute or method that will be called in each content object to index its values. This is useful, for example, if you want to create an index named 'Address' from the values returned by the getAddress() method.
The 'column' node will register a new column in the metadata table of the Plone Catalog Tool, so to include it in the returned brains.
Some index types has different properties which can be set up using 'property' and 'extra' nodes. For example, the default 'modified' index in Plone is registered with the following code:
<index name="modified" meta_type="DateIndex"> <property name="index_naive_time_as_local">True</property> </index>
Here, the property specifies that the time stored will be the local time instead of the UTC time.
Another example is the default 'SearchableText' field:
<index name="SearchableText" meta_type="ZCTextIndex"> <indexed_attr value="SearchableText"/> <extra name="index_type" value="Okapi BM25 Rank"/> <extra name="lexicon_id" value="plone_lexicon"/> </index>
Here, the index_type attribute specifies the ranking strategy for the index. For searches in text indexes, the results are returned in order of relevancy - the algorithm used to order the results is the ranking strategy. The available ranking stragegies are Okapi BM25 Rank and Cosine Measure. See The sorting subsection of the Searching and Categorizing Content section of The Zope Book for details on this.
The lexicon_id specifies the lexicon used for the text index. Lexicons process and store the words from the text and help in processing queries, for example, turning the text into lowercase or removing very common words in a language like "the" or "and". See The Lexicons subsection of the Searching and Categorizing Content section of The Zope Book for details on this.

Author: