Relation fields/widget in Plone 5

I am trying to implement a relation field that restricts on object_provides like below

foobar= RelationList(
    title=_(u'Foo bar'),
    default=[],
    required=False,
    value_type=RelationChoice(title=_(u'Foo'),
                              source=CatalogSource(
                                  object_provides='path.to.my.interface'), )
)

This "works", except searching in the field does not have any effect. Perhaps I should not use CatalogSource but instead create a named vocabulary? I tried to find documentation on this but https://docs.plone.org/external/plone.app.dexterity/docs/advanced/references.html appears to be out of date. All of the functionality it is talking about looks to be more of a 4.3 thing, with plone.formwidget.contenttree/autocomplete instead of the new select2 stuff.

It would also be nice to know how to use the AjaxSelectFieldWidget with relations as well.

Plone 5.0.5

Look at https://training.plone.org/5/mastering_plone/relations.html. Maybe that helps.

This is mostly an error on my part. What I had above is indeed correct and that in itself will result in something searchable. But I have a collective.elasticsearch configuration and that removes the superfluous ZCTextIndexes. Obviously the machinery isn't set up to interact with elasticsearch here, it's just trying to do a catalog search on a nonexistent index. I misinterpreted that as being a problem with CatalogSource.

I do think the documentation I linked above could stand to be updated. Philip's link seems to confirm my belief that it is antiquated in favor of using plone.app.vocabularies tools and plone.app.z3cform widgets.

On the off change anyone is interested, the reason it didn't support searching is because it generates a search query that looks like this

{'object_provides': 'path.to.my.interface', 'sort_on': u'sortable_title', 'sort_order': 'ascending', u'SearchableText': {'query': u'framework*'}}

collective.elasticsearch seems to support a value for SearchableText being a str/unicode, but not a dict. I will either patch that or subclass CatalogSource.