Problem/Motivation
As of #3075695: Move search_index() and related functions to a service Drupal core changed the way search indexing works.
This module was never updated to match the new system.
This means that anything you try to index with core 8.8.x silently "works", but the {search_totals} table is never updated.
If you start with a clean search index on an 8.8.x core site, you'll never get any search results displayed, since the query for search results JOINs against {search_totals}, which is empty.
Calling this "critical" since the fundamental functionality of the module is now broken.
Proposed resolution
Update src/Plugin/Search/SearchExcludeNodeSearch.php to use core's new API.
In particular:
SearchExcludeNodeSearch::updateIndex()
currently does this:
$node_storage = $this->entityManager->getStorage('node');
foreach ($node_storage->loadMultiple($nids) as $node) {
$this->indexNode($node);
}
Core's NodeSearch::updateIndex()
now looks more like this:
$node_storage = $this->entityTypeManager->getStorage('node');
$words = [];
try {
foreach ($node_storage->loadMultiple($nids) as $node) {
$words += $this->indexNode($node);
}
}
finally {
$this->searchIndex->updateWordWeights($words);
}
Remaining tasks
Update the search_exclude plugin(see #2),ideally in such a way that it still works with both 8.7.x core and 8.8.x(see #3).- Consider adding automated tests to this module so we would have noticed this sooner.
- Review.
- RTBC.
- Commit.
User interface changes
None.
API changes
TBD.
Data model changes
None.
Release notes snippet
TBD.
Comment | File | Size | Author |
---|---|---|---|
#3 | 3108145_2_3.interdiff.txt | 430 bytes | dww |
#3 | 3108145-3.patch | 762 bytes | dww |
Comments
Comment #2
dwwInitial patch that works okay in local testing. Pretty sure this will blow up spectacularly on 8.7.x core sites. So either this needs to go into a new 8.x-2.x branch, or it needs to be modified to conditionally do this or not based on what version of the core search API it discovers (e.g. checking for the existence of the
$this->searchIndex
protected variable or something.But it's a start. ;) If you don't care about 8.7.x, this patch might be all you need to get your search index working again with 8.8.x core.
Comment #3
dwwThis works on both 8.8.x and 8.7.x.
Comment #4
dwwIn Slack, @kim.pepper pointed out #3087407: Search indexing calls are inefficient as also related...
Comment #5
andypostAs quickfix it looks good, but strange that no language passed to indexNode()
++ To add a basic test
Comment #6
shderuiter CreditAttribution: shderuiter at Dutch Open Projects commentedCustomer site (Drupal 8.8.3) using this module had problems with certain search terms. Using patch 3 fixed the problem.
Comment #7
johne CreditAttribution: johne at CivicActions for LINCS commented#3 works great.
Comment #8
DanielVezaTested this manually + 2 positive comments about the patch solving issues.
++ To adding tests. I'll open that as a seperate ticket
Comment #10
DanielVezaThanks everyone.
Comment #11
DanielVezaOpened #3149523: [META] Add tests
Comment #12
dwwGreat, thanks! Following #3149523 now.
Comment #14
PapaGrande@DanielVeza, could we get another release that includes this fix? Thanks.