• 
      

    Search: Add get_es_client() to ES backend and update SignalProcessor

    Review Request #15053 — Created May 13, 2026 and updated

    Information

    Review Board
    release-8.x

    Reviewers

    Two targeted changes to existing files:
    - ElasticsearchBackend.get_es_client() — adds a new method to the
    Elasticsearch search backend that constructs and returns a raw
    elasticsearch.Elasticsearch client using the URL from the current backend
    configuration. Used by FacetedSearchEngine to run direct ES queries outside
    of Haystack. Raises RuntimeError if the installed elasticsearch package
    is unsupported.
    - SignalProcessor — extends handle_save and handle_delete to call
    FacetCache().invalidate_group(group_id) after each successful index update.
    A _MODEL_TO_GROUP mapping at module level translates the model class name
    to its facet cache group ID, covering ReviewRequest, User, Profile,
    Group, and all comment model types (Comment, GeneralComment,
    FileAttachmentComment, ScreenshotComment). Unrecognised model types are
    silently ignored. Cache invalidation is skipped when the index update itself
    raises an exception.

    Group.users M2M changes are also handled: when users are added to or removed
    from a group the affected user records are re-indexed and the user group's
    cache is invalidated.

    Ran full test suite.
    Verified that get_es_client returns a correctly configured Elasticsearch
    client and raises RuntimeError for unsupported package versions. Verified
    that SignalProcessor invalidates the correct facet cache group after save and
    delete for all tracked model types, silently ignores unrecognised models, and
    does not propagate indexing exceptions. Confirmed existing backend and signal
    processor behaviour is unchanged.

    Summary ID
    Search: Add get_es_client() to ES backend and update SignalProcessor
    171b5c9ecbfbe28250b16ea3444851fafde6a582
    Updated styling to match standard
    66c1ba16c101b1723e3803d9784004e01ab8b6c3
    Description From Last Updated

    continuation line over-indented for visual indent Column: 36 Error code: E127

    reviewbot reviewbot

    line too long (82 > 79 characters) Column: 80 Error code: E501

    reviewbot reviewbot

    line too long (80 > 79 characters) Column: 80 Error code: E501

    reviewbot reviewbot

    line too long (81 > 79 characters) Column: 80 Error code: E501

    reviewbot reviewbot

    line too long (81 > 79 characters) Column: 80 Error code: E501

    reviewbot reviewbot

    continuation line over-indented for visual indent Column: 36 Error code: E127

    reviewbot reviewbot

    line too long (82 > 79 characters) Column: 80 Error code: E501

    reviewbot reviewbot

    line too long (80 > 79 characters) Column: 80 Error code: E501

    reviewbot reviewbot

    'reviewboard.search.testing.search_enabled' imported but unused Column: 1 Error code: F401

    reviewbot reviewbot

    'reviewboard.search.search_backend_registry' imported but unused Column: 1 Error code: F401

    reviewbot reviewbot

    line too long (80 > 79 characters) Column: 80 Error code: E501

    reviewbot reviewbot

    'reviewboard.search.testing.search_enabled' imported but unused Column: 1 Error code: F401

    reviewbot reviewbot

    'reviewboard.search.search_backend_registry' imported but unused Column: 1 Error code: F401

    reviewbot reviewbot
    Checks run (1 failed, 1 succeeded)
    flake8 failed.
    JSHint passed.

    flake8

    dan.casares
    dan.casares
    Review request changed
    Change Summary:

    Updated signal_processor.py to properly reindex a review request when a comment, review, issue, etc. is published on that review request.
    Updated tests to ensure this is tracked correctly.

    Testing Done:
    ~  

    Verified that get_es_client returns a correctly configured Elasticsearch

      ~

    Ran full test suite.

      + Verified that get_es_client returns a correctly configured Elasticsearch
        client and raises RuntimeError for unsupported package versions. Verified
        that SignalProcessor invalidates the correct facet cache group after save and
        delete for all tracked model types, silently ignores unrecognised models, and
        does not propagate indexing exceptions. Confirmed existing backend and signal
        processor behaviour is unchanged.

    Commits:
    Summary ID Author
    Search: Add get_es_client() to ES backend and update SignalProcessor
    3c33a032f9e0104d5343802ac9a0c8282894ea00 DanielCasaresIglesias
    Search: Add get_es_client() to ES backend and update SignalProcessor
    3343cbafea00a0aba52011b1de6ebda931f40798 Daniel Casares-Iglesias

    Checks run (1 failed, 1 succeeded)

    flake8 failed.
    JSHint passed.

    flake8

    dan.casares
    Review request changed
    Commits:
    Summary ID
    Search: Add get_es_client() to ES backend and update SignalProcessor
    3343cbafea00a0aba52011b1de6ebda931f40798
    Search: Add get_es_client() to ES backend and update SignalProcessor
    171b5c9ecbfbe28250b16ea3444851fafde6a582
    Updated styling to match standard
    b508db3f9253792cce09ac01f3144aa0a8ef7277

    Checks run (1 failed, 1 succeeded)

    flake8 failed.
    JSHint passed.

    flake8

    dan.casares
    Review request changed
    Commits:
    Summary ID
    Search: Add get_es_client() to ES backend and update SignalProcessor
    171b5c9ecbfbe28250b16ea3444851fafde6a582
    Updated styling to match standard
    b508db3f9253792cce09ac01f3144aa0a8ef7277
    Search: Add get_es_client() to ES backend and update SignalProcessor
    171b5c9ecbfbe28250b16ea3444851fafde6a582
    Updated styling to match standard
    66c1ba16c101b1723e3803d9784004e01ab8b6c3

    Checks run (2 succeeded)

    flake8 passed.
    JSHint passed.