Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

From the Search Service admin, triggering a full reindex on a single index does not work #100

Open
2 tasks done
adunn49 opened this issue Jan 27, 2025 · 0 comments
Open
2 tasks done

Comments

@adunn49
Copy link

adunn49 commented Jan 27, 2025

Module version(s) affected

3.0.4

Description

This module provides a Search Service admin on which you can do a full reindex on a single index - this is the blue button within the gridfield labelled Trigger Full Index.

Clicking on this button adds a new Reindex job to the queued jobs labelled something like 'Search service reindex all documents in index andrew-dev-content', but when this is run it completes without error, but it does not index anything, even though there are documents to be indexed.

How to reproduce

Added dependencies (to silverstripe installer)

    "silverstripeltd/silverstripe-elasticappsearch": "^2.1",
    "silverstripe/silverstripe-search-service-elastic": "^1.1"

YML configuration

The yml configuration used is followed from the read me documentation but looks something like ...

SilverStripe\Core\Injector\Injector:
  SilverStripe\SearchService\Service\IndexConfiguration:
    constructor:
      index_variant: '`ENTERPRISE_SEARCH_ENGINE_PREFIX`'

SilverStripe\SearchService\Service\IndexConfiguration:
  crawl_page_content: false
  indexes:
    # This key is the name of the Elastic App Search 'engine' (prefixed with index_variant that we override above and set in .env)
    content:

Reproducing the issue

Once the elastic service is up and running, log into the CMS and ensure you have some pages that should be indexed, but ensure that you have cleared the index so that we can verify that the reindex all button does not work.
Go to the Search Service admin and click on the blue reindex all button for the single index.
This should create a job for doing a full reindex
Run the job
Go back to the search service admin and for the index, verify that the document count is still 0.
If you log into the elastic dashboard you can also check the api log and verify that no documents were sent.

Possible Solution

The reason this is not working appears to be how the relevant indexes for indexing is resolved, referring to https://github.com/silverstripe/silverstripe-search-service/blob/3/src/Service/IndexConfiguration.php#L108-L114 where, having debugged this, seen that $indexes is returned as an empty array, and therefore the reason for not indexing anything.

Relevant things to note here is that:

A possible solution here, within the code that checks for matching indexes, to append the index variant so that we are matching like for like, for example ...

        foreach (array_keys($indexes) as $index) {
            // note onlyIndexes includes the index variant, so append that when checking for matching key
            if (!in_array(sprintf('%s-%s', $this->indexVariant, $index), $this->onlyIndexes)) {
                unset($indexes[$index]);
            }
        }

Additional Context

No response

Validations

  • Check that there isn't already an issue that reports the same bug
  • Double check that your reproduction steps work in a fresh installation of silverstripe/installer (with any code examples you've provided)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant