1

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>
4

1 回答 1

1

Plone 搜索字段仅使用SearchableText索引。

这是一个全文索引,大多数类型使用应包含在结果中的所有字段的连接结果(字符串)填充。

有一个collective.dexteritytextindexer可以更轻松地填充SearchableText敏捷类型的索引。

将该包中的行为添加到您的类型中:

 <property name="behaviors">
     <element value="collective.dexteritytextindexer.behavior.IDexterityTextIndexer" />
 </property>

然后将您的varenummer字段标记为索引的一部分:

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"),
        )
于 2013-04-24T13:36:39.507 回答