Problem/Motivation
In Drupal 11.4 The Article and Page content types are removed from the Standard profile and recipe via #3587118: Remove content types from the standard install profile and recipe so if you try to install Database Search Defaults you get this error:
$ drush install search_api search_api_db_defaults
[error] Unable to install module 'search_api_db_defaults' due to unmet requirement(s):
- Content type article not found. Database Search Defaults module could not be installed.
- Content type page not found. Database Search Defaults module could not be installed.
┌ The search_api_db module's install requirements failed. Do you wish to continue? ┐
│ No │
└──────────────────────────────────────────────────────────────────────────────────┘
Steps to reproduce
Try to install The Database Search Defaults module in Drupal 11.4 and get an error.
Proposed resolution
We need a content type for the Database Search Defaults module, and a possible workaround could be to include an Article content type as a recipe in Search API?
After Article and Page were removed, I often find I need a content type in a fresh install, to quickly test something, and found the https://github.com/DrupalizeMe/dme_example_recipe repo from Lullabot. It's called "Blog" which can of course be changed. I added a PR to make it more similar to Article, adding an Image and Tags field, but without a Comment field.
We can tweak this recipe into being essentially the same as Article, but without a Comment field, and use it here?
Remaining tasks
To make the Database Search Defaults module work again in Drupal 11.4, with the least amount of disturbance in the existing code and tests we could do this:
- ✅ Add an Article content type recipe, replicating the old one, minus Comment field. This is in the MR, and ready for test:
$ cd web $ drush recipe modules/contrib/search_api/recipes/article 2/2 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] Applied Article content type recipe. [OK] Article content type applied successfully - ☐ Add a Page content type recipe, replicating the old one
- ☐ Remove Comment bits (code and test) from the Database Search Defaults module
- ☐ Create a documentation page which describes why and how to create Article and Page content types via recipes, i.e. running something like
drush recipe modules/contrib/search_api/recipes/article
Issue fork search_api-3615198
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
ressaI created an Article recipe as a proof of concept, and can create a Page recipe as well, if this method should be pursued?
Comment #4
ressaAdding related issue.
Comment #5
drunken monkeyThanks for reporting this problem!
However, with Core moving more and more away from rigid installation profiles towards more flexible/customized ways to create sites, it seems like the Database Search Defaults module might need a larger overhaul after all. Maybe we can figure out a way for it to create the search index dynamically, based on what’s there, instead of having a fixed config object that the site needs to be fitted around.
Something like #2574895: Add a wizard for easily creating a search setup might be an even better solution, but probably also even more work.
Anyways, I don’t think providing a recipe to create a content type is something the Search API module should do. Nobody will want to add a content type just so they can add a search to their site.
Comment #6
drunken monkeyOn reflection, I’m closing this in favor of #3346305: Rework Database Search Defaults to remain relevant. We’ll just discuss how to adapt the Defaults module going forward there.
Still, thanks again for reporting this!
Comment #8
ressaThanks for taking a look this @drunken monkey, and yes -- it was a bit of a kludgy solution :)
Creating a search index dynamically based on what’s available would be a much better solution (I guess, something like "if there's a content type, then add any text and image/media fields to the index"), so I'll follow along in that other issue, and looking forward to see how it turns out.
PS. About:
I largely agree, though from my perspective, the Database Search Defaults should mostly be viewed as a demo module, and users should install it to kick the tires of Search API, and see what it's capable of in a test Drupal site, not install it in a production site.