[Product-Developers] Full text search on custom types

Maurits van Rees m.van.rees at zestsoftware.nl
Mon Feb 7 17:10:55 UTC 2011


Hi Gil,

Op 07-02-11 11:13, Gil Forcada schreef:
> Hi,
>
> I have a site which has some custom Archtypes documents and I recently
> find out that when doing a search on the Plone site it doesn't return
> those documents when the search string is inside the documents' main body.
>
> The documents' field is called "body" whereas on the default Archtypes
> is called "text" so the field wasn't indexed.
>
> I cataloged the body filed but still the searches doesn't return the
> documents.
>
> Which led my to the SearchableText index, which, correct me if I'm
> wrong, is the one used when searching.
>
> I created TTW an index which seemed to work fine, but then when I
> exported it to Generic Setup's xml it didn't work, see it below:
>
> <index name="SearchableText" meta_type="ZCTextIndex">
> <indexed_attr value="SearchableText,getBody" />
> <extra name="index_type" value="Okapi BM25 Rank" />
> <extra name="lexicon_id" value="plone_lexicon" />
> </index>
>
> Any idea why does this happen? Is this the correct approach on getting
> your custom fields be used when doing a search?

No, don't do it like this.

Instead, look at Products/ATContentTypes/content/document.py: in its 
text field definition it has searchable=True.  Add that to the field 
definition in your custom schema and it should work: undo your changes 
to the catalog and reindex the SearchableText index and you should be 
able to find your content now.

See also the definition of SearchableText in 
Products/Archetypes/BaseObject.py

Cheers,

-- 
Maurits van Rees
Web App Programmer at Zest Software: http://zestsoftware.nl
Personal website: http://maurits.vanrees.org/




More information about the Product-Developers mailing list