A few day ago I've tested the Search API Module in combination with the Database search Module, the Search pages Module and the Multi-index searches Module. I set up a View to search two indexes simultaneously. That worked quite fine.
Today I realized, that there is a new version of the Search API Module, which has the ability to create a Item type "multiple Types". So I decided to give this a try.
But as soon as I create an Index of "multiple Types" (even if I include only nodes) the view formerly created does not work any more. I get the following error messages accessing the view:
Notice: Undefined index: fields in SearchApiIndex->getFulltextFields() (line 937 of MyWebserver\sites\all\modules\search_api\includes\index_entity.inc).
Warning: Invalid argument supplied for foreach() in SearchApiIndex->getFulltextFields() (line 938 of MyWebserver\sites\all\modules\search_api\includes\index_entity.inc).
SearchApiException: Could not determine the active index of the datasource. in SearchApiCombinedEntityDataSourceController->getCallingIndex() (line 308 of MyWebserver\sites\all\modules\search_api\includes\datasource_multiple.inc).
If I add nodes to the index and mark taxonomy-fields (included in the node) to be indexed I get the additional error (already after saving the fields if the index):
Notice: Undefined index: entity type in entity_views_field_definition() (line 215 of MyWebserver\sites\all\modules\entity\views\entity.views.inc).
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | 2563793-9--multiple_types_issues.patch | 1.91 KB | drunken monkey |
Comments
Comment #2
smitty commentedIt seems that the first issue (fields in SearchApiIndex->getFulltextFields(), Invalid argument supplied for foreach(), SearchApiException) is fixed after installing the Search Views Empty Query Module (https://www.drupal.org/project/search_api_views_empty_query) and applying the patch from https://www.drupal.org/node/2563777 (Don't ask my "Why"! I did not steep into the code, I just noticed that the errors did not occur any more after installing that module ...
The second issue (entity type in entity_views_field_definition()) seems to be a similar problem to https://www.drupal.org/node/1851334. So a similar patch fixes it.
Comment #3
drunken monkeyIt seems more like the first issue was caused by you not having set any fields for the index yet, could that be the case?
Still, I guess we should check for that in the code.
The other fix of course makes sense, too (even though your patch does not apply, for some reason).
Attaching a new patch for both problems, please test!
PS: It seems you (like many others – it's really easy to misinterpret) are confused by the "Issue tags" field. As the guidelines state, they aren't meant for free text tags related to the issue, but only for specific categorization purposes, usually by module maintainers.
So, if you aren't sure your current usage is correct, please just leave the field empty.
Also, please set the status to "Needs review" if there is already a working patch in the issue (or "Needs work" if the patch isn't complete yet).
Comment #5
smitty commentedFirst of all: Sorry for my "unprofessional" posting(;-)
I didn't want to use the Issue tags - must have happened accidentally. And yes, I forgot to change the status (because I was happy, that I had fond a workaround). I hope I'll do better next time ...
Yes, I hadn't set up the fields yet, when I copied the messages. That was because I had detected the problems having set up a working index and wanted to test if its really the "Multiple Types" feature which was causing the problems. So I deleted the Multiple Types Index and began from scratch again. And as soon I had created a new index the problems were there again.
Could it be, that my patch didn't apply because I am working on a Windows System and it was made by WinMerge? Unfortunately WinMerge does not allow to apply a patch, so I don't have a way to test the patch (for myself I make use of all patches manually at the moment).
I've tested your patch now and after applying it the first two messages (Undefined index; Invalid argument) have disappeared when the index has no fields yet.
But: The SearchApiException is still there (while accessing the view using the Multi-Index Searches Module, see initial post) - no matter if the Multiple Types Index has fields or not:
SearchApiException: Could not determine the active index of the datasource. in SearchApiCombinedEntityDataSourceController->getCallingIndex() (Zeile 308 von E:\Webserver\wamp\www\multisite-test-1\sites\all\modules\search_api\includes\datasource_multiple.inc).As I mentioned this can be fixed by installing the Search Views Empty Query Module (but only if the patch from https://www.drupal.org/node/2563777 is installed too (Of course this is only a workaround and does not solve the problem). So I think there must be another issue to fix ...
Comment #6
ReBa commented@drunken-monkey
When does the code break by only doing the $table['entity type'] = NULL code?
Could this be because you also have to add $table['skip entity load']?
For me, at this point, I'm using my patch (based on previous patches) and everything seems fine, I've not encountered any problems yet.
Comment #7
smitty commentedThe last patch does not solve the SearchApiException from #5.
Comment #8
feyp commentedWith patch #3 applied, I lost the option to choose the "Rendered entity" row plugin (I guess it is provided by the entity module) for all search api views. Patch #6 works fine so far.
Comment #9
drunken monkey@ smitty: For the Multi-Index Searches issue, see #2580975: Fix incompatibility with "Multiple types" indexes.
Otherwise, the attached patch should work now and be the simplest solution, I think. Please test/review!
I don't really know whether
skip entity loadis needed even if we don't set an entity type, but I guess it can't do any harm and it simplifies the code.Comment #10
drunken monkeyCommitted.