mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-27 04:25:06 +08:00
test index update
This commit is contained in:
parent
68692a256e
commit
4c5effe714
@ -1,13 +1,13 @@
|
|||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
|
||||||
use milli::update::{IndexDocumentsMethod, UpdateFormat};
|
|
||||||
use async_compression::tokio_02::write::GzipEncoder;
|
use async_compression::tokio_02::write::GzipEncoder;
|
||||||
use futures_util::stream::StreamExt;
|
use futures_util::stream::StreamExt;
|
||||||
|
use milli::update::{IndexDocumentsMethod, UpdateFormat};
|
||||||
use tokio::io::AsyncWriteExt;
|
use tokio::io::AsyncWriteExt;
|
||||||
|
|
||||||
use super::Data;
|
|
||||||
use crate::index_controller::{IndexController, Settings, IndexSettings, IndexMetadata};
|
|
||||||
use crate::index_controller::UpdateStatus;
|
use crate::index_controller::UpdateStatus;
|
||||||
|
use crate::index_controller::{IndexController, Settings, IndexSettings, IndexMetadata};
|
||||||
|
use super::Data;
|
||||||
|
|
||||||
impl Data {
|
impl Data {
|
||||||
pub async fn add_documents<B, E>(
|
pub async fn add_documents<B, E>(
|
||||||
|
@ -24,4 +24,13 @@ impl Index<'_> {
|
|||||||
});
|
});
|
||||||
self.service.post("/indexes", body).await
|
self.service.post("/indexes", body).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn update(&self, primary_key: Option<&str>) -> (Value, StatusCode) {
|
||||||
|
let body = json!({
|
||||||
|
"primaryKey": primary_key,
|
||||||
|
});
|
||||||
|
let url = format!("/indexes/{}", self.uid);
|
||||||
|
|
||||||
|
self.service.put(url, body).await
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -165,23 +165,6 @@ impl Server {
|
|||||||
//(response, status_code)
|
//(response, status_code)
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//pub async fn put_request(&mut self, url: &str, body: Value) -> (Value, StatusCode) {
|
|
||||||
//eprintln!("put_request: {}", url);
|
|
||||||
|
|
||||||
//let mut app =
|
|
||||||
//test::init_service(meilisearch_http::create_app(&self.data, true).wrap(NormalizePath)).await;
|
|
||||||
|
|
||||||
//let req = test::TestRequest::put()
|
|
||||||
//.uri(url)
|
|
||||||
//.set_json(&body)
|
|
||||||
//.to_request();
|
|
||||||
//let res = test::call_service(&mut app, req).await;
|
|
||||||
//let status_code = res.status();
|
|
||||||
|
|
||||||
//let body = test::read_body(res).await;
|
|
||||||
//let response = serde_json::from_slice(&body).unwrap_or_default();
|
|
||||||
//(response, status_code)
|
|
||||||
//}
|
|
||||||
|
|
||||||
//pub async fn put_request_async(&mut self, url: &str, body: Value) -> (Value, StatusCode) {
|
//pub async fn put_request_async(&mut self, url: &str, body: Value) -> (Value, StatusCode) {
|
||||||
//eprintln!("put_request_async: {}", url);
|
//eprintln!("put_request_async: {}", url);
|
||||||
|
@ -35,5 +35,21 @@ impl Service {
|
|||||||
let response = serde_json::from_slice(&body).unwrap_or_default();
|
let response = serde_json::from_slice(&body).unwrap_or_default();
|
||||||
(response, status_code)
|
(response, status_code)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn put(&self, url: impl AsRef<str>, body: Value) -> (Value, StatusCode) {
|
||||||
|
let mut app =
|
||||||
|
test::init_service(meilisearch_http::create_app(&self.0, true).wrap(NormalizePath)).await;
|
||||||
|
|
||||||
|
let req = test::TestRequest::put()
|
||||||
|
.uri(url.as_ref())
|
||||||
|
.set_json(&body)
|
||||||
|
.to_request();
|
||||||
|
let res = test::call_service(&mut app, req).await;
|
||||||
|
let status_code = res.status();
|
||||||
|
|
||||||
|
let body = test::read_body(res).await;
|
||||||
|
let response = serde_json::from_slice(&body).unwrap_or_default();
|
||||||
|
(response, status_code)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
mod create_index;
|
mod create_index;
|
||||||
mod get_index;
|
mod get_index;
|
||||||
|
mod update_index;
|
||||||
|
Loading…
Reference in New Issue
Block a user