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).

Comments

smitty created an issue. See original summary.

smitty’s picture

StatusFileSize
new592 bytes

It 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.

drunken monkey’s picture

Status: Active » Needs review
Issue tags: -multiple Types
StatusFileSize
new1.43 KB

It 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).

Status: Needs review » Needs work

The last submitted patch, 3: 2563793-3--undefined_array_indexes.patch, failed testing.

smitty’s picture

First 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 ...

ReBa’s picture

StatusFileSize
new589 bytes

@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.

smitty’s picture

The last patch does not solve the SearchApiException from #5.

feyp’s picture

With 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.

drunken monkey’s picture

Version: 7.x-1.16 » 7.x-1.x-dev
Status: Needs work » Needs review
StatusFileSize
new1.91 KB

@ 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 load is needed even if we don't set an entity type, but I guess it can't do any harm and it simplifies the code.

drunken monkey’s picture

Status: Needs review » Fixed

Committed.

  • drunken monkey committed a5d4bf7 on 7.x-1.x
    Issue #2563793 by drunken monkey, smitty, ReBa: Fixed Views base table...

Status: Fixed » Closed (fixed)

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