I have several node types with default Title and Body fields.
Search index with this fields was created.
Drush config export/import works greate but Body field can not be imported for search index if I use profile install. I have no errors during theme install, search_api.index.SOME_NAME.yml has Body field.
But after import, I have only Title field.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kashandarash created an issue. See original summary.

drunken monkey’s picture

Status: Active » Postponed (maintainer needs more info)

It seems the index is installed before the body field is, is that possible? Does the index (in the profile) correctly specify its dependency on the body field? (If it does, I think Core's config management should automatically take care of importing this in the right order. Although maybe those are also defined in different modules, and the profile doesn't define the correct dependencies for those?)

kashandarash’s picture

Status: Postponed (maintainer needs more info) » Needs review

Yes, index is installed before the body field.
When I moved config to theme optional folder it worked.
But first time I did not have an error about dependencies, during install it is just skipped the field it should not be like that.

drunken monkey’s picture

Status: Needs review » Closed (works as designed)

OK, so is the dependency actually listed in the exported config file of the profile you're installing?
In any case, this is either a bug in the profile (wrong dependencies for either the exported index config, or the module containing it) or in Drupal Core's config management.
It would only be a bug in our module if the correctly saved index wouldn't contain the body field in its dependencies. (In that case, please re-open.)

Also, please see the Status settings of issues handbook page: "Needs review" only applies if there is a patch. Otherwise, it's just "Active".

oeklesund’s picture

Status: Closed (works as designed) » Needs review
FileSize
858 bytes

I had a similar issue. Only the field base would get exported in the config, which is not enough. Attached is a patch with a potential fix.

oeklesund’s picture

Here an upgraded version. The underlying problem is that search_api is exporting the field dependencies to base fields. During installation, even if the field are there, it might be that there are no instances for it, which will result in failure. So we need to create a dependency to the field instance instead of the field base.

Status: Needs review » Needs work

The last submitted patch, 6: export_field_base-2838586-6.patch, failed testing.

oeklesund’s picture

Modified tests accordingly

oeklesund’s picture

drunken monkey’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 8: export_field_base-2838586-7.patch, failed testing.

drunken monkey’s picture

Component: General code » Framework

With "field base" I guess you mean the field storage?
That's on purpose, see #2472917: Make index configuration depend on field storage not instances and #2541206: Consider field storage dependency removal on Index. So, just reverting that will only lead to regressions in other areas.

It is a tricky problem, though, I admit. That field storages and field instances are separate (yet closely intertwined) config entities really causes a lot of problems. (Very possibly it solves yet more problems – but still.)
I can't really think of a way to resolve all of those issues – either you use (or include) the field instances, in which case you have dependency problems when removing just one field instance, and also explicitly depend on the exact bundle names; or you use the field storages, potentially ending up with unresolved dependencies during installation.

I actually thought #2792277: Respect the "syncing" state when saving an entity might have fixed these problems – just don't perform any such checks during config syncing. But it seems that doesn't apply during profile install? Or are you using a module version older than Beta 3?

For installation profiles, though, I guess you still have the option of just adjusting the module dependencies? Or are the default configs installed in bulk after all modules in that case?