Problem/Motivation

The CollectDatasource plugin for Search API contains some obscure tricks to make properties of multiple schema configs available simultaneously. After selecting the Collect plugin, you can choose which schemas should be included, and then the union of their fields are available as sub-properties under the schemas.

This makes the code and the UI overly complex.

A possibility that has been overlooked is to derive datasource plugins from schema configs. Thus the intermediate step of grouping properties per schema is eliminated.

Search API already natively supports selecting multiple datasources for an index, so the possibility to include multiple schemas is retained.

Proposed resolution

Create a deriver for the datasource plugin, which creates one derivative for each schema config.
Adapt the plugin to being defined for a single schema config.

Remaining tasks

User interface changes

API changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

miro_dietiker’s picture

Priority: Normal » Major

There is a disadvantage of this approach.

If multiple datasources define a common field, it will result in multiple fields. They can not be indexed as a common one with this approach.

There are other approaches to deal with this problem. This is in general what was discussed under the term mapping.
We need to map multiple separate definitions into a common space so that collect processing creates this common denominator.
Before switching, we need to understand the side effects and how this mapping would could be implemented. And then, we need to decide if/hoch much of it we require to be implemented first or as a followup.

And since this changes data storage of index and need reconfiguration of everything, it is major.

Arla’s picture

Issue summary has a screenshot of field configuration before the patch. Here's also a screenshot of the index configuration:

Now here's screenshots from index and field configuration after the patch:

Arla’s picture

Rerolled.

Tested manually by installing collect_demo. The search page looks as expected, and new containers are automatically indexed.

Status: Needs review » Needs work

The last submitted patch, 3: derive-datasource-2492731-3.patch, failed testing.

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 3: derive-datasource-2492731-3.patch, failed testing.

Status: Needs work » Needs review
Arla’s picture

Let's discuss whether this is an useful change or not.

To counter #1:

If multiple datasources define a common field, it will result in multiple fields. They can not be indexed as a common one with this approach.

This is actually also the case with the current single-plugin approach. The interesting feature of "semantic cross-domain property mapping" (as I would name it) is thus quite separate from this issue.

Another disadvantage with this approach is that an index can no longer be configured as "all models except X and Y". With one datasource per model, they must be positively selected. I'm not sure how much of a problem that is.

miro_dietiker’s picture

The "all" problem is not relevant.
Each of the plugins has separate structure of data. Just enabling all sources will not lead to any job done. You will always need to enable the fields additionally.

So i agree, it's much more different entity types (different sources) than bundles / variants if a specific entity type.
- Without the mapping, the definitions are separate anyway.
- With the mapping, we can also cover the type relation of bundles.

Arla’s picture

Status: Needs review » Reviewed & tested by the community

Cool, then let's commit it. I just tested manually again, with success.

  • Arla committed bd56f79 on 8.x-1.x
    Issue #2492731 by Arla: Derive search_api datasource plugins by schema...
Arla’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.