Closed (fixed)
Project:
Search API
Version:
8.x-1.x-dev
Component:
General code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
9 Aug 2016 at 08:12 UTC
Updated:
15 Oct 2022 at 14:56 UTC
Jump to comment: Most recent
Comments
Comment #2
drholera commentedIt looks like you can't install Database Search Defaults module if you have changed one of 'body', 'comment', 'field_tags', 'field_image' fields in article CT. Or if you change 'body' field in CT Page to field_body for example.
You can fix it for your site:
1. Change
- field.field.node.article.commentto- field.field.node.article.field_commentin your search_api_db_defaults/config/optional/core.entity_view_display.node.article.search_index.yml (line 7)2. Change
- field.field.node.article.commentto- field.field.node.article.field_commentin your search_api_db_defaults/config/optional/core.entity_view_display.node.article.search_result.yml (line 7)3. Change
'article' => array('body', 'comment', 'field_tags', 'field_image'),to the'article' => array('body', 'field_comment', 'field_tags', 'field_image'),in your search_api_db_defaults/search_api_db_defaults.install (line 19)After these steps, Database Search Default will install correctly.
Comment #3
drunken monkey@ drholera: Thanks a lot for your help here!
Seems a good answer, I hope this solved it.
Comment #5
cpatrone commentedIt is a good answer. I created Article and Page content, I made the changes and it worked. Thank you @drholera
Comment #6
geerlingguy commentedThe suggestion also works for enabling the Solr Search Defaults module (just in the corresponding solr module files)—however, I still got a message:
But everything else was created successfully, and I didn't see anything in the database log, so go figure.
Comment #7
kate_raquel commentedMuchas Gracias, Solucionado a la perfección!
Thank you @drholera, perfect solutión.
Comment #8
carnerik commentedI'm having the same issue because I had uninstalled the Comments module prior to installing Search API. I can complete (and have completed) the first two steps as described in comment #1, but I guess the code has changed in search_api_db_defaults/search_api_db_defaults.install, because I don't see
'article' => array('body', 'comment', 'field_tags', 'field_image'),. Lines 10-27 in my file look like this:Is there somewhere else I should look?
Comment #9
carnerik commentedFound it.
'article' => array('body', 'comment', 'field_tags', 'field_image'),is located in search_api/src/IndexListBuilder.php on line 68. Changed 'comment' to 'field_comment' and now the module installs. (Again, this is after creating a Comment field called "field_comment" on the Article content type and following the first two steps from comment #1.) @drholera Thanks again!Comment #10
benjarlett commented#9 worked for me.
Comment #11
rfletcher73 commentedHi there, I just ran into this issue myself. Is there a way when the Search API module is installed that it can gather the name of the fields from in Drupal ? Maybe by writing it to a file or storing the settings into the database?
You could do a check that if any fields are missing read the settings from the db or the flat file.
I think there needs to be a way to "future" proof the installer otherwise if someone makes changes, deletes a field and what-not, you can't install your module.
I'm using the latest version of the Search API plugin. I do not think this issue is fixed.
I did follow the steps above and edited the couple of files and that did fix the issue.
Thanks for posting that work-around. I'd still like to see the improvement made to the module though.
Comment #12
rfaySo I got this problem by trying to use solr with the umami distribution, which does not have "article" set up with comments. And I guess that's the problem. With a standard install it worked OK.
Comment #13
oluwatoyint commented#9 worked for me. You will also have to create the field_tags in the article content type.
For drupal 8.85 You have to go to structure/types on the admin menu, and then modify the article content type.
Comment #14
Doomd commentedI found this thread because I had the same exact problem when trying to install the corresponding Solr API Defaults modules (search_api_solr_defaults). Similar to the instructions above, the defaults module would fail to install unless I replaced references to the "comment" field with "field_comment" in the following files:
And of course, as mentioned in a comment above, since I had to install the comment module from scratch, I had to re-create the comment type "comment" (for content). In my articles content type, I added a comments field called "field_comment" which referenced this comment type.
I do agree with #11 that assuming that the comment field exists (since many sites don't need or want comments), AND assuming that the field is called "comment" is a bit inflexible, especially since re-installation of the comments module forces new fields to be prepended with "field_". At the very least, if it's too hard to perform a check for "comment" or "field_comment", if "comment" is missing...it should simply be skipped and the install should still proceed. Indexing comments is hardly necessary...AND they can always be added to an index later.
Comment #15
captaindav commentedI was able to work around this issue by:
1) Do a clean install of Drupal 8 Core w/comment enabled.
2) Export the config. (drush cex)
3) Enable Database Search Defaults, verify defaults are correctly set.
4) Determine which config changed by navigating to /admin/config/development/configuration
5) Export the changed config files manually and import them into the site where Database Search Defaults is not working.
Comment #16
subir_ghoshThis was very useful. #1 + #9.