mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-03 20:07:09 +02:00
rename data to meilisearch
This commit is contained in:
parent
42a6260b65
commit
dfce44fa3b
6 changed files with 31 additions and 31 deletions
|
@ -88,12 +88,12 @@ pub fn configure(cfg: &mut web::ServiceConfig) {
|
|||
}
|
||||
|
||||
pub async fn get_document(
|
||||
data: GuardedData<Public, MeiliSearch>,
|
||||
meilisearch: GuardedData<Public, MeiliSearch>,
|
||||
path: web::Path<DocumentParam>,
|
||||
) -> Result<HttpResponse, ResponseError> {
|
||||
let index = path.index_uid.clone();
|
||||
let id = path.document_id.clone();
|
||||
let document = data
|
||||
let document = meilisearch
|
||||
.document(index, id, None as Option<Vec<String>>)
|
||||
.await?;
|
||||
debug!("returns: {:?}", document);
|
||||
|
@ -120,7 +120,7 @@ pub struct BrowseQuery {
|
|||
}
|
||||
|
||||
pub async fn get_all_documents(
|
||||
data: GuardedData<Public, MeiliSearch>,
|
||||
meilisearch: GuardedData<Public, MeiliSearch>,
|
||||
path: web::Path<IndexParam>,
|
||||
params: web::Query<BrowseQuery>,
|
||||
) -> Result<HttpResponse, ResponseError> {
|
||||
|
@ -136,7 +136,7 @@ pub async fn get_all_documents(
|
|||
Some(names)
|
||||
});
|
||||
|
||||
let documents = data
|
||||
let documents = meilisearch
|
||||
.documents(
|
||||
path.index_uid.clone(),
|
||||
params.offset.unwrap_or(DEFAULT_RETRIEVE_DOCUMENTS_OFFSET),
|
||||
|
@ -157,7 +157,7 @@ pub struct UpdateDocumentsQuery {
|
|||
/// Route used when the payload type is "application/json"
|
||||
/// Used to add or replace documents
|
||||
pub async fn add_documents(
|
||||
data: GuardedData<Private, MeiliSearch>,
|
||||
meilisearch: GuardedData<Private, MeiliSearch>,
|
||||
path: web::Path<IndexParam>,
|
||||
params: web::Query<UpdateDocumentsQuery>,
|
||||
body: Payload,
|
||||
|
@ -169,7 +169,7 @@ pub async fn add_documents(
|
|||
method: IndexDocumentsMethod::ReplaceDocuments,
|
||||
format: DocumentAdditionFormat::Json,
|
||||
};
|
||||
let update_status = data
|
||||
let update_status = meilisearch
|
||||
.register_update(path.index_uid.as_str(), update)
|
||||
.await?;
|
||||
|
||||
|
@ -180,7 +180,7 @@ pub async fn add_documents(
|
|||
/// Route used when the payload type is "application/json"
|
||||
/// Used to add or replace documents
|
||||
pub async fn update_documents(
|
||||
data: GuardedData<Private, MeiliSearch>,
|
||||
meilisearch: GuardedData<Private, MeiliSearch>,
|
||||
path: web::Path<IndexParam>,
|
||||
params: web::Query<UpdateDocumentsQuery>,
|
||||
body: Payload,
|
||||
|
@ -192,7 +192,7 @@ pub async fn update_documents(
|
|||
method: IndexDocumentsMethod::UpdateDocuments,
|
||||
format: DocumentAdditionFormat::Json,
|
||||
};
|
||||
let update_status = data
|
||||
let update_status = meilisearch
|
||||
.register_update(path.index_uid.as_str(), update)
|
||||
.await?;
|
||||
|
||||
|
|
|
@ -76,16 +76,16 @@ pub struct UpdateIndexResponse {
|
|||
}
|
||||
|
||||
pub async fn get_index(
|
||||
data: GuardedData<Private, MeiliSearch>,
|
||||
meilisearch: GuardedData<Private, MeiliSearch>,
|
||||
path: web::Path<IndexParam>,
|
||||
) -> Result<HttpResponse, ResponseError> {
|
||||
let meta = data.get_index(path.index_uid.clone()).await?;
|
||||
let meta = meilisearch.get_index(path.index_uid.clone()).await?;
|
||||
debug!("returns: {:?}", meta);
|
||||
Ok(HttpResponse::Ok().json(meta))
|
||||
}
|
||||
|
||||
pub async fn update_index(
|
||||
data: GuardedData<Private, MeiliSearch>,
|
||||
meilisearch: GuardedData<Private, MeiliSearch>,
|
||||
path: web::Path<IndexParam>,
|
||||
body: web::Json<UpdateIndexRequest>,
|
||||
) -> Result<HttpResponse, ResponseError> {
|
||||
|
@ -95,7 +95,7 @@ pub async fn update_index(
|
|||
uid: body.uid,
|
||||
primary_key: body.primary_key,
|
||||
};
|
||||
let meta = data
|
||||
let meta = meilisearch
|
||||
.update_index(path.into_inner().index_uid, settings)
|
||||
.await?;
|
||||
debug!("returns: {:?}", meta);
|
||||
|
@ -111,10 +111,10 @@ pub async fn update_index(
|
|||
//}
|
||||
|
||||
pub async fn get_index_stats(
|
||||
data: GuardedData<Private, MeiliSearch>,
|
||||
meilisearch: GuardedData<Private, MeiliSearch>,
|
||||
path: web::Path<IndexParam>,
|
||||
) -> Result<HttpResponse, ResponseError> {
|
||||
let response = data.get_index_stats(path.index_uid.clone()).await?;
|
||||
let response = meilisearch.get_index_stats(path.index_uid.clone()).await?;
|
||||
|
||||
debug!("returns: {:?}", response);
|
||||
Ok(HttpResponse::Ok().json(response))
|
||||
|
|
|
@ -82,13 +82,13 @@ impl From<SearchQueryGet> for SearchQuery {
|
|||
}
|
||||
|
||||
pub async fn search_with_url_query(
|
||||
data: GuardedData<Public, MeiliSearch>,
|
||||
meilisearch: GuardedData<Public, MeiliSearch>,
|
||||
path: web::Path<IndexParam>,
|
||||
params: web::Query<SearchQueryGet>,
|
||||
) -> Result<HttpResponse, ResponseError> {
|
||||
debug!("called with params: {:?}", params);
|
||||
let query = params.into_inner().into();
|
||||
let search_result = data.search(path.into_inner().index_uid, query).await?;
|
||||
let search_result = meilisearch.search(path.into_inner().index_uid, query).await?;
|
||||
|
||||
// Tests that the nb_hits is always set to false
|
||||
#[cfg(test)]
|
||||
|
@ -99,12 +99,12 @@ pub async fn search_with_url_query(
|
|||
}
|
||||
|
||||
pub async fn search_with_post(
|
||||
data: GuardedData<Public, MeiliSearch>,
|
||||
meilisearch: GuardedData<Public, MeiliSearch>,
|
||||
path: web::Path<IndexParam>,
|
||||
params: web::Json<SearchQuery>,
|
||||
) -> Result<HttpResponse, ResponseError> {
|
||||
debug!("search called with params: {:?}", params);
|
||||
let search_result = data
|
||||
let search_result = meilisearch
|
||||
.search(path.into_inner().index_uid, params.into_inner())
|
||||
.await?;
|
||||
|
||||
|
|
|
@ -37,11 +37,11 @@ pub struct UpdateParam {
|
|||
}
|
||||
|
||||
pub async fn get_update_status(
|
||||
data: GuardedData<Private, MeiliSearch>,
|
||||
meilisearch: GuardedData<Private, MeiliSearch>,
|
||||
path: web::Path<UpdateParam>,
|
||||
) -> Result<HttpResponse, ResponseError> {
|
||||
let params = path.into_inner();
|
||||
let meta = data
|
||||
let meta = meilisearch
|
||||
.update_status(params.index_uid, params.update_id)
|
||||
.await?;
|
||||
let meta = UpdateStatusResponse::from(meta);
|
||||
|
@ -50,10 +50,10 @@ pub async fn get_update_status(
|
|||
}
|
||||
|
||||
pub async fn get_all_updates_status(
|
||||
data: GuardedData<Private, MeiliSearch>,
|
||||
meilisearch: GuardedData<Private, MeiliSearch>,
|
||||
path: web::Path<IndexParam>,
|
||||
) -> Result<HttpResponse, ResponseError> {
|
||||
let metas = data.all_update_status(path.into_inner().index_uid).await?;
|
||||
let metas = meilisearch.all_update_status(path.into_inner().index_uid).await?;
|
||||
let metas = metas
|
||||
.into_iter()
|
||||
.map(UpdateStatusResponse::from)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue