Fatal error: Call to a member function getBoost() on null in /var/www/drupalvm/modules/contrib/search_api_solr/src/Plugin/search_api/backend/SearchApiSolrBackend.php on line 839
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | 2868704-9--validate_query_fulltext_fields.patch | 3.3 KB | drunken monkey |
Comments
Comment #2
sandeepguntaka commentedComment #3
mkalkbrennerI don't think that this is the correct fix. There must be a reason why the $document is NULL. That's the real bug and your patch just hides it.
Can you provide further information or a stack trace?
Comment #4
richard.c.allen2386 commentedThis is happening to us currently because we removed a field from the index I think.
Full stack.
Comment #5
mkalkbrennerMaybe we're getting closer now. Does the error go away when you re-index?
Comment #6
richard.c.allen2386 commentedNope, from what I can tell, in, SearchApiSolrBackEnd:890
I was additionally running into this separate issue which was fixed, by using the work around. Disabled and enabled the index. They may be related.
https://www.drupal.org/node/2749101
edit: ps, I'm on this until it's fixed, I'm around in irc @ justAllgood or allgood on the slack if you want to debug in real time.
Comment #7
mkalkbrennerthanks for that information. I move this issue to Search API because it seems to be caused there.
Comment #8
richard.c.allen2386 commentedI was able to find I think, the reason the error is caused.
In my views.view..yml which was using our search index, I found found a reference to our full text search filter. It seems if you delete the field, the reference to the field sticks around. Example: yml below:
Removing field_planogram_description: field_planogram_description and running config-import (or removing the filter from views_ui, I assume) cleared up the issue.
Comment #9
drunken monkeyHm, yeah, I guess it makes sense to validate the input there, by default, and only return fulltext fields that are actually known for the index. Backends with other supported fulltext fields can still override the method to add those, too.
Patch attached, along with a test case. Please test/review whether it fixes this problem!
A second step in fixes this would probably be to update views if an index is edited – but that's a lot more work, and pretty tricky, I'd say, so fixing the fatal error should be good enough for now. (It's probably even debatable if we should really go around adapting other modules' configuration like that.)
Come to think of it, fixing this in the Views fulltext filter plugin would also have been an option. But I guess this is the "safer" fix, also making sure this is handled correctly for, e.g., Search API Pages.
Comment #10
drunken monkey(Any idea why this doesn't trigger the test bot?)
Comment #11
richard.c.allen2386 commentedAbove patch appears to be working for me.
Comment #12
borisson_I like this, the code is simple and it has good test-coverage, @drunken monkey++
Comment #14
drunken monkeyGood to hear, thanks for testing and reviewing!
Committed.
Thanks again, everyone!