pub trait SearchClientPlugin: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn search(
&self,
index: &str,
query: &SearchQuery,
) -> Result<SearchResults, SearchError>;
fn index(&self, index: &str, docs: Vec<Document>) -> Result<(), SearchError>;
fn delete(&self, index: &str, ids: Vec<String>) -> Result<(), SearchError>;
// Provided method
fn is_healthy(&self) -> bool { ... }
}Expand description
A search backend.
The runtime holds one instance per configured backend and dispatches
search.query, search.index, and search.delete host calls
through it. All three methods are sync; backends that need async
transport wrap it internally. Every method takes an explicit index
name so a single backend can host many logical collections — this
matches Meili, Elastic, Typesense, and the pg-FTS convention of
“one index == one table”.
Required Methods§
Sourcefn search(
&self,
index: &str,
query: &SearchQuery,
) -> Result<SearchResults, SearchError>
fn search( &self, index: &str, query: &SearchQuery, ) -> Result<SearchResults, SearchError>
Execute a query against index. See SearchQuery for the shape.
An empty result is Ok(SearchResults { hits: vec![], .. }).
IndexNotFound means the index itself is missing; BadQuery
means the query was malformed; Backend is everything else.
Sourcefn index(&self, index: &str, docs: Vec<Document>) -> Result<(), SearchError>
fn index(&self, index: &str, docs: Vec<Document>) -> Result<(), SearchError>
Upsert documents into index. Documents with an id that already
exists are replaced; new ids are inserted. Bulk semantics — the
call is one round-trip per backend batch, not per document.
Sourcefn delete(&self, index: &str, ids: Vec<String>) -> Result<(), SearchError>
fn delete(&self, index: &str, ids: Vec<String>) -> Result<(), SearchError>
Delete documents from index by id. Missing ids are silently
ignored — deleting a non-existent document is not an error (same
convention as Redis DEL, S3 DeleteObject, and every other
idempotent delete in the plugin API).
Provided Methods§
Sourcefn is_healthy(&self) -> bool
fn is_healthy(&self) -> bool
Health check. Default: always healthy. Remote backends should
override to ping their transport so the runtime can route
around a dead provider without blowing up in search.