MeiliSearch/meilisearch-http/src/data/search.rs

35 lines
980 B
Rust
Raw Normal View History

2021-02-16 18:21:16 +01:00
use serde_json::{Map, Value};
2020-12-12 13:32:06 +01:00
2020-12-29 11:11:06 +01:00
use super::Data;
2021-03-15 18:11:10 +01:00
use crate::index::{SearchQuery, SearchResult};
use crate::index_controller::error::Result;
2020-12-12 13:32:06 +01:00
2020-12-29 11:11:06 +01:00
impl Data {
2021-06-15 17:39:07 +02:00
pub async fn search(&self, index: String, search_query: SearchQuery) -> Result<SearchResult> {
2021-03-15 16:52:05 +01:00
self.index_controller.search(index, search_query).await
2020-12-24 12:58:34 +01:00
}
2021-02-10 17:08:37 +01:00
2021-03-04 14:20:19 +01:00
pub async fn retrieve_documents(
2021-02-10 17:08:37 +01:00
&self,
2021-03-04 14:20:19 +01:00
index: String,
offset: usize,
limit: usize,
attributes_to_retrieve: Option<Vec<String>>,
) -> Result<Vec<Map<String, Value>>> {
2021-03-15 18:11:10 +01:00
self.index_controller
.documents(index, offset, limit, attributes_to_retrieve)
.await
2021-02-10 17:08:37 +01:00
}
2021-02-11 10:59:23 +01:00
2021-03-04 15:09:00 +01:00
pub async fn retrieve_document(
2021-02-11 10:59:23 +01:00
&self,
2021-03-15 16:52:05 +01:00
index: String,
document_id: String,
2021-03-04 15:09:00 +01:00
attributes_to_retrieve: Option<Vec<String>>,
) -> Result<Map<String, Value>> {
2021-03-15 18:11:10 +01:00
self.index_controller
.document(index, document_id, attributes_to_retrieve)
.await
2021-02-11 10:59:23 +01:00
}
2020-12-24 12:58:34 +01:00
}