plone / plone.restapi

RESTful API for Plone.
http://plonerestapi.readthedocs.org/
84 stars 73 forks source link

In content that uses the plone.blocks behavior, it is not possible to add fields to SearchableText with "plone.app.dexterity.textindexer" #1764

Closed wesleybl closed 3 months ago

wesleybl commented 3 months ago

I wanted to add a field from a behavior to the SearchableText index of a Plone base content. So I did as the documentation shows:

https://6.docs.plone.org/backend/indexing.html#textindexer

In other words, I created a behavior similar to:

from plone.app.dexterity import textindexer
from plone.supermodel.model import Schema
from plone import schema

class IMyBehavior(Schema):

    textindexer.searchable('specialfield')
    specialfield = schema.Text(title=u'Special field')

But the do field has not added to SearchableText.

The base content uses the plone.blocks behavior. Content that uses this behavior has a SearchableText definition:

https://github.com/plone/plone.restapi/blob/a29583a51b58b0245ce0d58acf1e518f49367131/src/plone/restapi/indexers.py#L111

Maybe this index should use Extending indexed data?

wesleybl commented 3 months ago

When I removed the plone.blocks behavior from the content, my behavior field was added to the SearchableText.

davisagli commented 3 months ago

@wesleybl I think this is the same issue as https://github.com/plone/plone.restapi/issues/1744, right?

wesleybl commented 3 months ago

@davisagli oh yes it is the same issue.

wesleybl commented 3 months ago

@davisagli regarding compatibility with Plone 5, can we use zcml:condition?

davisagli commented 3 months ago

@wesleybl Probably. I didn't find time to think about it in detail yet.

wesleybl commented 3 months ago

Closing because it is a duplicate of: #1744