Using Search component with custom indexes

Hello everyone,

I am trying to create a custom search component, that will make search queries for different indexes. This component redirects the URL to the default search component for the queries.

On the default search component, it normally searches the “SearchableText” index, and this query returns the results even if the keyword is written partially.

Example URL: /search?SearchableText=testpage
Result: returns also the page with name “test”

But if I search other indexes, it only returns the correct results if the full name of the index is written.

If I am searching for an object named ‘testobject’;
Example URL: /search?SearchableText=&objectName=test
Result: Doesn’t return unrelated results

Example URL: /search?SearchableText=&objectName=testobject
Result: Returns the correct result.

I am using KeywordIndex meta type at this index.

  <index meta_type="KeywordIndex" name="objectName" >
    <indexed_attr value="objectName" />

Has anyone tackled with this problem before?
Is this related to the index's meta type?
If so, which type of index type should I use, if not, how can I achieve this?

This documentation is still valid (though collective.dexteritytextindexer got merged into core a while ago)

SearchableText indexer is a fulltext search index (ZCTextIndex internally) which collects arbitrary data from your object (title, description, text, keywords etc ...) and it can be extended with AND and OR and * for searching parts of words.

KeywordIndex indexes and searches for the exact words (eg. Subject).

EDIT: you can see what's indexed in the catalog if you go to portal_catalog/Catalog tab and click on the path in the list below. There you see the Index Contents for searching and Metadata Contents which is returned by the catalog brain.

1 Like

Thank you so much Peter.
I now had the chance to try your solution, and it worked.

Also, thanks for the documentation link: it helped me to fill the gaps in my knowledge.

For the people who will see this in the future:
This works for the partial searching:

  <index meta_type="ZCTextIndex"
    <indexed_attr value="artwork_author" />
    <extra name="index_type"
           value="Okapi BM25 Rank"
    <extra name="lexicon_id"

And this doesn't:

  <index meta_type="KeywordIndex"
    <indexed_attr value="artwork_author" />