2021-02-26 09:10:04 +01:00
|
|
|
//use async_compression::tokio_02::write::GzipEncoder;
|
|
|
|
//use futures_util::stream::StreamExt;
|
2021-02-26 17:14:11 +01:00
|
|
|
use milli::update::{IndexDocumentsMethod, UpdateFormat};
|
2021-02-26 09:10:04 +01:00
|
|
|
//use tokio::io::AsyncWriteExt;
|
|
|
|
use actix_web::web::Payload;
|
2020-12-29 11:11:06 +01:00
|
|
|
|
2021-02-01 19:51:47 +01:00
|
|
|
use crate::index_controller::UpdateStatus;
|
2021-02-26 09:10:04 +01:00
|
|
|
use crate::index_controller::{Settings, IndexMetadata};
|
2021-02-18 20:28:10 +01:00
|
|
|
use super::Data;
|
2020-12-29 11:11:06 +01:00
|
|
|
|
|
|
|
impl Data {
|
2021-02-26 17:14:11 +01:00
|
|
|
pub async fn add_documents(
|
2020-12-29 11:11:06 +01:00
|
|
|
&self,
|
2021-02-01 19:51:47 +01:00
|
|
|
index: impl AsRef<str> + Send + Sync + 'static,
|
2020-12-29 11:11:06 +01:00
|
|
|
method: IndexDocumentsMethod,
|
|
|
|
format: UpdateFormat,
|
2021-03-03 10:57:13 +01:00
|
|
|
stream: Payload,
|
2021-02-13 12:22:59 +01:00
|
|
|
primary_key: Option<String>,
|
2021-02-01 19:51:47 +01:00
|
|
|
) -> anyhow::Result<UpdateStatus>
|
2020-12-29 11:11:06 +01:00
|
|
|
{
|
2021-03-03 10:57:13 +01:00
|
|
|
let update_status = self.index_controller.add_documents(index.as_ref().to_string(), method, format, stream, primary_key).await?;
|
2021-02-26 09:10:04 +01:00
|
|
|
Ok(update_status)
|
2020-12-29 11:11:06 +01:00
|
|
|
}
|
|
|
|
|
2021-02-01 19:51:47 +01:00
|
|
|
pub async fn update_settings(
|
2021-01-01 16:59:49 +01:00
|
|
|
&self,
|
2021-02-26 09:10:04 +01:00
|
|
|
_index: impl AsRef<str> + Send + Sync + 'static,
|
|
|
|
_settings: Settings
|
2021-02-01 19:51:47 +01:00
|
|
|
) -> anyhow::Result<UpdateStatus> {
|
2021-02-26 09:10:04 +01:00
|
|
|
todo!()
|
|
|
|
//let index_controller = self.index_controller.clone();
|
|
|
|
//let update = tokio::task::spawn_blocking(move || index_controller.update_settings(index, settings)).await??;
|
|
|
|
//Ok(update.into())
|
2021-01-01 16:59:49 +01:00
|
|
|
}
|
2020-12-29 11:11:06 +01:00
|
|
|
|
2021-02-11 12:03:00 +01:00
|
|
|
pub async fn clear_documents(
|
|
|
|
&self,
|
2021-02-26 09:10:04 +01:00
|
|
|
_index: impl AsRef<str> + Sync + Send + 'static,
|
2021-02-11 12:03:00 +01:00
|
|
|
) -> anyhow::Result<UpdateStatus> {
|
2021-02-26 09:10:04 +01:00
|
|
|
todo!()
|
|
|
|
//let index_controller = self.index_controller.clone();
|
|
|
|
//let update = tokio::task::spawn_blocking(move || index_controller.clear_documents(index)).await??;
|
|
|
|
//Ok(update.into())
|
2021-02-11 12:03:00 +01:00
|
|
|
}
|
|
|
|
|
2021-02-12 17:39:14 +01:00
|
|
|
pub async fn delete_documents(
|
|
|
|
&self,
|
2021-02-26 09:10:04 +01:00
|
|
|
_index: impl AsRef<str> + Sync + Send + 'static,
|
|
|
|
_document_ids: Vec<String>,
|
2021-02-12 17:39:14 +01:00
|
|
|
) -> anyhow::Result<UpdateStatus> {
|
2021-02-26 09:10:04 +01:00
|
|
|
todo!()
|
|
|
|
//let index_controller = self.index_controller.clone();
|
|
|
|
//let update = tokio::task::spawn_blocking(move || index_controller.delete_documents(index, document_ids)).await??;
|
|
|
|
//Ok(update.into())
|
2021-02-12 17:39:14 +01:00
|
|
|
}
|
|
|
|
|
2021-02-15 10:53:21 +01:00
|
|
|
pub async fn delete_index(
|
|
|
|
&self,
|
2021-02-26 09:10:04 +01:00
|
|
|
_index: impl AsRef<str> + Send + Sync + 'static,
|
2021-02-15 10:53:21 +01:00
|
|
|
) -> anyhow::Result<()> {
|
2021-02-26 09:10:04 +01:00
|
|
|
todo!()
|
|
|
|
//let index_controller = self.index_controller.clone();
|
|
|
|
//tokio::task::spawn_blocking(move || { index_controller.delete_index(index) }).await??;
|
|
|
|
//Ok(())
|
2021-02-15 10:53:21 +01:00
|
|
|
}
|
|
|
|
|
2021-01-28 17:20:51 +01:00
|
|
|
#[inline]
|
2021-02-01 19:51:47 +01:00
|
|
|
pub fn get_update_status(&self, index: impl AsRef<str>, uid: u64) -> anyhow::Result<Option<UpdateStatus>> {
|
2021-02-26 09:10:04 +01:00
|
|
|
todo!()
|
|
|
|
//self.index_controller.update_status(index, uid)
|
2021-01-28 17:20:51 +01:00
|
|
|
}
|
2020-12-30 19:17:13 +01:00
|
|
|
|
2021-02-01 19:51:47 +01:00
|
|
|
pub fn get_updates_status(&self, index: impl AsRef<str>) -> anyhow::Result<Vec<UpdateStatus>> {
|
2021-02-26 09:10:04 +01:00
|
|
|
todo!()
|
|
|
|
//self.index_controller.all_update_status(index)
|
2021-01-28 18:32:24 +01:00
|
|
|
}
|
2021-02-09 11:26:52 +01:00
|
|
|
|
|
|
|
pub fn update_index(
|
|
|
|
&self,
|
|
|
|
name: impl AsRef<str>,
|
|
|
|
primary_key: Option<impl AsRef<str>>,
|
|
|
|
new_name: Option<impl AsRef<str>>
|
|
|
|
) -> anyhow::Result<IndexMetadata> {
|
2021-02-26 09:10:04 +01:00
|
|
|
todo!()
|
|
|
|
//let settings = IndexSettings {
|
|
|
|
//name: new_name.map(|s| s.as_ref().to_string()),
|
|
|
|
//primary_key: primary_key.map(|s| s.as_ref().to_string()),
|
|
|
|
//};
|
2021-02-09 11:26:52 +01:00
|
|
|
|
2021-02-26 09:10:04 +01:00
|
|
|
//self.index_controller.update_index(name, settings)
|
2021-02-09 11:26:52 +01:00
|
|
|
}
|
2020-12-29 11:11:06 +01:00
|
|
|
}
|