Reputation: 59
I have created a new dexterity type, and the type is working nicely, and title turns up nicely in the Plone search results. However I need to index the rest of the fields aswell.
Following the Dexterity manual I have created an @indexer and catalog, and I can see in portal_catalog that the "varenummer" index is filled with the correct column data.
My problem is though that I cant search on a "Varenummer" in the plone search field.
Any ideas?
I have the following schema set up in vare.py
class IVare(form.Schema):
"""Leverandør type, som kan oprettes alle steder.
"""
title = schema.TextLine(
title=_(u"Varenavn"),
)
varenummer = schema.TextLine(
title=_(u"Varenummer"),
)
stoerrelse = schema.TextLine(
title=_(u"Størrelse"),
)
enhed = schema.TextLine(
title=_(u"Enhed"),
)
pris = schema.TextLine(
title=_(u"Pris"),
)
@indexer(IVare)
def varenummerIndexer(obj):
"""Create a catalogue indexer, registered as an adapter, which can
populate the ``start`` index with the film's start date.
"""
return obj.varenummer
grok.global_adapter(varenummerIndexer, name="varenummer")
In catalog.xml I have defined:
<?xml version="1.0"?>
<object name="portal_catalog" meta_type="Plone Catalog Tool">
<index name="varenummer" meta_type="FieldIndex">
<indexed_attr value="varenummer"/>
</index>
<column value="varenummer"/>
</object>
Upvotes: 1
Views: 486
Reputation: 1124848
The Plone search field only uses the SearchableText
index.
This is a full text index that most types fill with the concatenated result (a string) of all fields that should be included in the results.
There is a collective.dexteritytextindexer
package that makes filling the SearchableText
index for dexterity types easier.
Add the behaviour from that package to your type:
<property name="behaviors">
<element value="collective.dexteritytextindexer.behavior.IDexterityTextIndexer" />
</property>
then mark your varenummer
field as part of the index:
from collective import dexteritytextindexer
class IVare(form.Schema):
"""Leverandør type, som kan oprettes alle steder.
"""
dexteritytextindexer.searchable('varenummer')
varenummer = schema.TextLine(
title=_(u"Varenummer"),
)
Upvotes: 1