We are getting a lot of notifications in the dblog due to the $fields array miss-matching with the $mlt['fields'] and creating issues when trying to access fields that didnt exist like the below for example.
Notice: Undefined index: field_sponsors in SearchApiSolrService->search() (line 876 of /path/sites/all/modules/contrib/search_api_solr/includes/service.inc).
I've trying stepping through all the code but there is just too much going on between search api, search api solr and views to find why this is occuring.
To replicate, have a site with many content types and many fields then create a solr view with 2 contextual filters, one can be content type, the other needs to be 'Search: More like this'.
I've supplied a patch with simply adds if (isset($fields[$f])) { inside the loop and this prevents the errors from occuring.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | 2447213-1--mlt_nonexistent_fields.patch | 1.03 KB | drunken monkey |
Comments
Comment #1
drunken monkeyThanks for reporting this issue!
I'd guess this comes from the fields selected in the "More like this" contextual filter not matching with the fields available in the index anymore (if fields were removed from the index after the filter was saved the last time).
To fix this, we should probably check for the existence of the fields right when adding them to the query, in the "More like this" Views handler.
The attached patch should do this. Please test it and see if it also resolves your problem!
Also, you seem relatively new to contributing (patches) on Drupal.org, so please let me give you a few tips for improving future contributions:
a/includes/service.inc, nota/all/modules/contrib/search_api_solr/includes/service.inc.Comment #2
drunken monkeyCould you please test the patch and verify it solves the problem for you?
Comment #3
drunken monkey