Search: Add get_es_client() to ES backend and update SignalProcessor
Review Request #15053 — Created May 13, 2026 and updated
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.Elasticsearchclient using the URL from the current backend
configuration. Used byFacetedSearchEngineto run direct ES queries outside
of Haystack. RaisesRuntimeErrorif the installedelasticsearchpackage
is unsupported.
-SignalProcessor— extendshandle_saveandhandle_deleteto call
FacetCache().invalidate_group(group_id)after each successful index update.
A_MODEL_TO_GROUPmapping at module level translates the model class name
to its facet cache group ID, coveringReviewRequest,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.usersM2M 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.
Verified that
get_es_clientreturns a correctly configured Elasticsearch
client and raisesRuntimeErrorfor unsupported package versions. Verified
thatSignalProcessorinvalidates 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 | Author |
|---|---|---|
| 3c33a032f9e0104d5343802ac9a0c8282894ea00 | DanielCasaresIglesias |