mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 20:37:15 +02:00
temp
This commit is contained in:
parent
d1e9ded76f
commit
b4d447b5cb
8 changed files with 70 additions and 238 deletions
|
@ -3,6 +3,7 @@ mod updates;
|
|||
|
||||
pub use search::{SearchQuery, SearchResult};
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::fs::create_dir_all;
|
||||
use std::ops::Deref;
|
||||
use std::sync::Arc;
|
||||
|
@ -10,7 +11,7 @@ use std::sync::Arc;
|
|||
use milli::Index;
|
||||
use sha2::Digest;
|
||||
|
||||
use crate::option::Opt;
|
||||
use crate::{option::Opt, updates::Settings};
|
||||
use crate::updates::UpdateQueue;
|
||||
|
||||
#[derive(Clone)]
|
||||
|
@ -82,6 +83,39 @@ impl Data {
|
|||
Ok(Data { inner })
|
||||
}
|
||||
|
||||
pub fn settings<S: AsRef<str>>(&self, _index: S) -> anyhow::Result<Settings> {
|
||||
let txn = self.indexes.env.read_txn()?;
|
||||
let fields_map = self.indexes.fields_ids_map(&txn)?;
|
||||
println!("fields_map: {:?}", fields_map);
|
||||
|
||||
let displayed_attributes = self.indexes
|
||||
.displayed_fields(&txn)?
|
||||
.map(|fields| {println!("{:?}", fields); fields.iter().filter_map(|f| fields_map.name(*f).map(String::from)).collect()})
|
||||
.unwrap_or_else(|| vec!["*".to_string()]);
|
||||
|
||||
let searchable_attributes = self.indexes
|
||||
.searchable_fields(&txn)?
|
||||
.map(|fields| fields
|
||||
.iter()
|
||||
.filter_map(|f| fields_map.name(*f).map(String::from))
|
||||
.collect())
|
||||
.unwrap_or_else(|| vec!["*".to_string()]);
|
||||
|
||||
let faceted_attributes = self.indexes
|
||||
.faceted_fields(&txn)?
|
||||
.iter()
|
||||
.filter_map(|(f, t)| Some((fields_map.name(*f)?.to_string(), t.to_string())))
|
||||
.collect::<HashMap<_, _>>()
|
||||
.into();
|
||||
|
||||
Ok(Settings {
|
||||
displayed_attributes: Some(Some(displayed_attributes)),
|
||||
searchable_attributes: Some(Some(searchable_attributes)),
|
||||
faceted_attributes: Some(faceted_attributes),
|
||||
criteria: None,
|
||||
})
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn http_payload_size_limit(&self) -> usize {
|
||||
self.options.http_payload_size_limit.get_bytes() as usize
|
||||
|
|
|
@ -7,7 +7,7 @@ use milli::update::{IndexDocumentsMethod, UpdateFormat};
|
|||
use milli::update_store::UpdateStatus;
|
||||
|
||||
use super::Data;
|
||||
use crate::updates::{UpdateMeta, UpdateResult};
|
||||
use crate::updates::{UpdateMeta, UpdateResult, UpdateStatusResponse, Settings};
|
||||
|
||||
impl Data {
|
||||
pub async fn add_documents<B, E, S>(
|
||||
|
@ -16,7 +16,7 @@ impl Data {
|
|||
method: IndexDocumentsMethod,
|
||||
format: UpdateFormat,
|
||||
mut stream: impl futures::Stream<Item=Result<B, E>> + Unpin,
|
||||
) -> anyhow::Result<UpdateStatus<UpdateMeta, String, String>>
|
||||
) -> anyhow::Result<UpdateStatusResponse>
|
||||
where
|
||||
B: Deref<Target = [u8]>,
|
||||
E: std::error::Error + Send + Sync + 'static,
|
||||
|
@ -45,6 +45,16 @@ impl Data {
|
|||
Ok(update.into())
|
||||
}
|
||||
|
||||
pub async fn update_settings<S: AsRef<str>>(
|
||||
&self,
|
||||
_index: S,
|
||||
settings: Settings
|
||||
) -> anyhow::Result<UpdateStatusResponse> {
|
||||
let meta = UpdateMeta::Settings(settings);
|
||||
let queue = self.update_queue.clone();
|
||||
let update = tokio::task::spawn_blocking(move || queue.register_update(meta, &[])).await??;
|
||||
Ok(update.into())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn get_update_status(&self, _index: &str, uid: u64) -> anyhow::Result<Option<UpdateStatus<UpdateMeta, UpdateResult, String>>> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue