mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-03 20:07:09 +02:00
Support JSON value as filters
This commit is contained in:
parent
3329248a84
commit
ee812b31c4
3 changed files with 8 additions and 7 deletions
|
@ -90,10 +90,9 @@ impl IndexScheduler {
|
||||||
request.send_json(settings.clone()).map_err(into_backoff_error)
|
request.send_json(settings.clone()).map_err(into_backoff_error)
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
// TODO support JSON Value objects
|
|
||||||
let filter = filter
|
let filter = filter
|
||||||
.as_deref()
|
.as_ref()
|
||||||
.map(Filter::from_str)
|
.map(Filter::from_json)
|
||||||
.transpose()
|
.transpose()
|
||||||
.map_err(|e| Error::from_milli(e, Some(uid.to_string())))?
|
.map_err(|e| Error::from_milli(e, Some(uid.to_string())))?
|
||||||
.flatten();
|
.flatten();
|
||||||
|
|
|
@ -8,6 +8,7 @@ use milli::update::IndexDocumentsMethod;
|
||||||
use milli::Object;
|
use milli::Object;
|
||||||
use roaring::RoaringBitmap;
|
use roaring::RoaringBitmap;
|
||||||
use serde::{Deserialize, Serialize, Serializer};
|
use serde::{Deserialize, Serialize, Serializer};
|
||||||
|
use serde_json::Value;
|
||||||
use time::{Duration, OffsetDateTime};
|
use time::{Duration, OffsetDateTime};
|
||||||
use utoipa::{schema, ToSchema};
|
use utoipa::{schema, ToSchema};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
@ -111,11 +112,11 @@ pub enum KindWithContent {
|
||||||
},
|
},
|
||||||
DocumentDeletionByFilter {
|
DocumentDeletionByFilter {
|
||||||
index_uid: String,
|
index_uid: String,
|
||||||
filter_expr: serde_json::Value,
|
filter_expr: Value,
|
||||||
},
|
},
|
||||||
DocumentEdition {
|
DocumentEdition {
|
||||||
index_uid: String,
|
index_uid: String,
|
||||||
filter_expr: Option<serde_json::Value>,
|
filter_expr: Option<Value>,
|
||||||
context: Option<milli::Object>,
|
context: Option<milli::Object>,
|
||||||
function: String,
|
function: String,
|
||||||
},
|
},
|
||||||
|
@ -174,7 +175,7 @@ pub struct IndexSwap {
|
||||||
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize, ToSchema)]
|
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize, ToSchema)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct ExportIndexSettings {
|
pub struct ExportIndexSettings {
|
||||||
pub filter: Option<String>,
|
pub filter: Option<Value>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl KindWithContent {
|
impl KindWithContent {
|
||||||
|
|
|
@ -12,6 +12,7 @@ use meilisearch_types::index_uid_pattern::IndexUidPattern;
|
||||||
use meilisearch_types::keys::actions;
|
use meilisearch_types::keys::actions;
|
||||||
use meilisearch_types::tasks::{ExportIndexSettings as DbExportIndexSettings, KindWithContent};
|
use meilisearch_types::tasks::{ExportIndexSettings as DbExportIndexSettings, KindWithContent};
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
use serde_json::Value;
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
use utoipa::{OpenApi, ToSchema};
|
use utoipa::{OpenApi, ToSchema};
|
||||||
|
|
||||||
|
@ -122,5 +123,5 @@ pub struct ExportIndexSettings {
|
||||||
#[schema(value_type = Option<String>, example = json!("genres = action"))]
|
#[schema(value_type = Option<String>, example = json!("genres = action"))]
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
#[deserr(default, error = DeserrJsonError<InvalidExportIndexFilter>)]
|
#[deserr(default, error = DeserrJsonError<InvalidExportIndexFilter>)]
|
||||||
pub filter: Option<String>,
|
pub filter: Option<Value>,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue