mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-03 03:47:02 +02:00
Better behavior when null indexes
This commit is contained in:
parent
ad03c86c44
commit
f4bb6cbca8
3 changed files with 13 additions and 10 deletions
|
@ -210,7 +210,7 @@ impl KindWithContent {
|
||||||
| SnapshotCreation
|
| SnapshotCreation
|
||||||
| TaskCancelation { .. }
|
| TaskCancelation { .. }
|
||||||
| TaskDeletion { .. }
|
| TaskDeletion { .. }
|
||||||
| Export { .. } // TODO Should I resolve the index names?
|
| Export { .. }
|
||||||
| UpgradeDatabase { .. } => vec![],
|
| UpgradeDatabase { .. } => vec![],
|
||||||
DocumentAdditionOrUpdate { index_uid, .. }
|
DocumentAdditionOrUpdate { index_uid, .. }
|
||||||
| DocumentEdition { index_uid, .. }
|
| DocumentEdition { index_uid, .. }
|
||||||
|
|
|
@ -81,15 +81,17 @@ async fn export(
|
||||||
|
|
||||||
let Export { url, api_key, payload_size, indexes } = export;
|
let Export { url, api_key, payload_size, indexes } = export;
|
||||||
|
|
||||||
let indexes = if indexes.is_empty() {
|
let indexes = match indexes {
|
||||||
BTreeMap::from([(IndexUidPattern::new_unchecked("*"), DbExportIndexSettings::default())])
|
Some(indexes) => indexes
|
||||||
} else {
|
|
||||||
indexes
|
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(pattern, ExportIndexSettings { filter })| {
|
.map(|(pattern, ExportIndexSettings { filter })| {
|
||||||
(pattern, DbExportIndexSettings { filter })
|
(pattern, DbExportIndexSettings { filter })
|
||||||
})
|
})
|
||||||
.collect()
|
.collect(),
|
||||||
|
None => BTreeMap::from([(
|
||||||
|
IndexUidPattern::new_unchecked("*"),
|
||||||
|
DbExportIndexSettings::default(),
|
||||||
|
)]),
|
||||||
};
|
};
|
||||||
|
|
||||||
let task = KindWithContent::Export {
|
let task = KindWithContent::Export {
|
||||||
|
@ -130,7 +132,7 @@ pub struct Export {
|
||||||
#[schema(value_type = Option<BTreeMap<String, ExportIndexSettings>>, example = json!({ "*": { "filter": null } }))]
|
#[schema(value_type = Option<BTreeMap<String, ExportIndexSettings>>, example = json!({ "*": { "filter": null } }))]
|
||||||
#[deserr(default)]
|
#[deserr(default)]
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub indexes: BTreeMap<IndexUidPattern, ExportIndexSettings>,
|
pub indexes: Option<BTreeMap<IndexUidPattern, ExportIndexSettings>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A wrapper around the `Byte` type that implements `Deserr`.
|
/// A wrapper around the `Byte` type that implements `Deserr`.
|
||||||
|
|
|
@ -15,9 +15,10 @@ impl ExportAnalytics {
|
||||||
let Export { url: _, api_key, payload_size, indexes } = export;
|
let Export { url: _, api_key, payload_size, indexes } = export;
|
||||||
|
|
||||||
let has_api_key = api_key.is_some();
|
let has_api_key = api_key.is_some();
|
||||||
let index_patterns_count = indexes.len();
|
let index_patterns_count = indexes.as_ref().map_or(0, |indexes| indexes.len());
|
||||||
let patterns_with_filter_count =
|
let patterns_with_filter_count = indexes.as_ref().map_or(0, |indexes| {
|
||||||
indexes.values().filter(|settings| settings.filter.is_some()).count();
|
indexes.values().filter(|settings| settings.filter.is_some()).count()
|
||||||
|
});
|
||||||
let payload_sizes =
|
let payload_sizes =
|
||||||
if let Some(crate::routes::export::ByteWithDeserr(byte_size)) = payload_size {
|
if let Some(crate::routes::export::ByteWithDeserr(byte_size)) = payload_size {
|
||||||
vec![byte_size.as_u64()]
|
vec![byte_size.as_u64()]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue