Skip to main content

SearchService

Struct SearchService 

Source
pub struct SearchService { /* private fields */ }
Expand description

搜索服务 (提供泛型封装)

Implementations§

Source§

impl SearchService

Source

pub fn new(backend: Box<dyn SearchBackend>) -> Self

从后端创建搜索服务

Source

pub async fn ping(&self) -> SearchResult<bool>

检查搜索服务是否可用

Source

pub async fn create_index( &self, index: &str, settings: Option<Value>, mappings: Option<Value>, ) -> SearchResult<bool>

创建索引

Source

pub async fn delete_index(&self, index: &str) -> SearchResult<bool>

删除索引

Source

pub async fn index_exists(&self, index: &str) -> SearchResult<bool>

检查索引是否存在

Source

pub async fn get_index(&self, index: &str) -> SearchResult<Value>

获取索引信息

Source

pub async fn index_document<T: Serialize + ?Sized>( &self, index: &str, id: Option<&str>, document: &T, ) -> SearchResult<String>

索引文档(创建或更新)

Source

pub async fn get_document<T: DeserializeOwned>( &self, index: &str, id: &str, ) -> SearchResult<Option<T>>

获取文档

Source

pub async fn update_document<T: Serialize + ?Sized>( &self, index: &str, id: &str, doc: &T, ) -> SearchResult<bool>

更新文档

Source

pub async fn delete_document(&self, index: &str, id: &str) -> SearchResult<bool>

删除文档

Source

pub async fn document_exists(&self, index: &str, id: &str) -> SearchResult<bool>

文档是否存在

Source

pub async fn bulk( &self, index: &str, operations: Vec<BulkOperation>, ) -> SearchResult<BulkResponse>

批量操作

Source

pub async fn search<T: DeserializeOwned>( &self, index: &str, query: SearchQuery, ) -> SearchResult<SearchResponse<T>>

搜索文档

Source

pub async fn delete_by_query( &self, index: &str, query: Value, ) -> SearchResult<u64>

按查询删除文档

Source

pub async fn update_by_query( &self, index: &str, query: Value, script: Value, ) -> SearchResult<u64>

按查询更新文档

Source

pub fn config(&self) -> &SearchConfig

获取搜索配置

Source

pub fn build_index_name(&self, index: &str) -> String

构建带前缀的完整索引名

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.