pub struct SearchService { /* private fields */ }Expand description
搜索服务 (提供泛型封装)
Implementations§
Source§impl SearchService
impl SearchService
Sourcepub fn new(backend: Box<dyn SearchBackend>) -> Self
pub fn new(backend: Box<dyn SearchBackend>) -> Self
从后端创建搜索服务
Sourcepub async fn ping(&self) -> SearchResult<bool>
pub async fn ping(&self) -> SearchResult<bool>
检查搜索服务是否可用
Sourcepub async fn create_index(
&self,
index: &str,
settings: Option<Value>,
mappings: Option<Value>,
) -> SearchResult<bool>
pub async fn create_index( &self, index: &str, settings: Option<Value>, mappings: Option<Value>, ) -> SearchResult<bool>
创建索引
Sourcepub async fn delete_index(&self, index: &str) -> SearchResult<bool>
pub async fn delete_index(&self, index: &str) -> SearchResult<bool>
删除索引
Sourcepub async fn index_exists(&self, index: &str) -> SearchResult<bool>
pub async fn index_exists(&self, index: &str) -> SearchResult<bool>
检查索引是否存在
Sourcepub async fn get_index(&self, index: &str) -> SearchResult<Value>
pub async fn get_index(&self, index: &str) -> SearchResult<Value>
获取索引信息
Sourcepub async fn index_document<T: Serialize + ?Sized>(
&self,
index: &str,
id: Option<&str>,
document: &T,
) -> SearchResult<String>
pub async fn index_document<T: Serialize + ?Sized>( &self, index: &str, id: Option<&str>, document: &T, ) -> SearchResult<String>
索引文档(创建或更新)
Sourcepub async fn get_document<T: DeserializeOwned>(
&self,
index: &str,
id: &str,
) -> SearchResult<Option<T>>
pub async fn get_document<T: DeserializeOwned>( &self, index: &str, id: &str, ) -> SearchResult<Option<T>>
获取文档
Sourcepub async fn update_document<T: Serialize + ?Sized>(
&self,
index: &str,
id: &str,
doc: &T,
) -> SearchResult<bool>
pub async fn update_document<T: Serialize + ?Sized>( &self, index: &str, id: &str, doc: &T, ) -> SearchResult<bool>
更新文档
Sourcepub async fn delete_document(&self, index: &str, id: &str) -> SearchResult<bool>
pub async fn delete_document(&self, index: &str, id: &str) -> SearchResult<bool>
删除文档
Sourcepub async fn document_exists(&self, index: &str, id: &str) -> SearchResult<bool>
pub async fn document_exists(&self, index: &str, id: &str) -> SearchResult<bool>
文档是否存在
Sourcepub async fn bulk(
&self,
index: &str,
operations: Vec<BulkOperation>,
) -> SearchResult<BulkResponse>
pub async fn bulk( &self, index: &str, operations: Vec<BulkOperation>, ) -> SearchResult<BulkResponse>
批量操作
Sourcepub async fn search<T: DeserializeOwned>(
&self,
index: &str,
query: SearchQuery,
) -> SearchResult<SearchResponse<T>>
pub async fn search<T: DeserializeOwned>( &self, index: &str, query: SearchQuery, ) -> SearchResult<SearchResponse<T>>
搜索文档
Sourcepub async fn delete_by_query(
&self,
index: &str,
query: Value,
) -> SearchResult<u64>
pub async fn delete_by_query( &self, index: &str, query: Value, ) -> SearchResult<u64>
按查询删除文档
Sourcepub async fn update_by_query(
&self,
index: &str,
query: Value,
script: Value,
) -> SearchResult<u64>
pub async fn update_by_query( &self, index: &str, query: Value, script: Value, ) -> SearchResult<u64>
按查询更新文档
Sourcepub fn config(&self) -> &SearchConfig
pub fn config(&self) -> &SearchConfig
获取搜索配置
Sourcepub fn build_index_name(&self, index: &str) -> String
pub fn build_index_name(&self, index: &str) -> String
构建带前缀的完整索引名
Auto Trait Implementations§
impl Freeze for SearchService
impl !RefUnwindSafe for SearchService
impl Send for SearchService
impl Sync for SearchService
impl Unpin for SearchService
impl UnsafeUnpin for SearchService
impl !UnwindSafe for SearchService
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more