mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-04-18 07:57:59 +02:00
Merge branch 'add-index-name-to-sort-error-message' of github.com:cisco877/meilisearch into add-index-name-to-sort-error-message
This commit is contained in:
commit
d00c187349
@ -311,9 +311,15 @@ fn create_or_open_index(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let Some((created, updated)) = date {
|
if let Some((created, updated)) = date {
|
||||||
Ok(Index::new_with_creation_dates(name, options, path, created, updated)?)
|
Ok(Index::new_with_creation_dates(
|
||||||
|
Some(String::from(name)),
|
||||||
|
options,
|
||||||
|
path,
|
||||||
|
created,
|
||||||
|
updated,
|
||||||
|
)?)
|
||||||
} else {
|
} else {
|
||||||
Ok(Index::new(name, options, path)?)
|
Ok(Index::new(Some(String::from(name)), options, path)?)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,9 +122,12 @@ only composed of alphanumeric characters (a-z A-Z 0-9), hyphens (-) and undersco
|
|||||||
InvalidFilter(String),
|
InvalidFilter(String),
|
||||||
#[error("Invalid type for filter subexpression: expected: {}, found: {1}.", .0.join(", "))]
|
#[error("Invalid type for filter subexpression: expected: {}, found: {1}.", .0.join(", "))]
|
||||||
InvalidFilterExpression(&'static [&'static str], Value),
|
InvalidFilterExpression(&'static [&'static str], Value),
|
||||||
#[error("Attribute `{}` of index `{}` is not sortable. {}",
|
#[error("Attribute `{}`{} is not sortable. {}",
|
||||||
.field,
|
.field,
|
||||||
.index,
|
match .index_name.is_some() {
|
||||||
|
true => format!(" of index `{}`", index_name.clone().unwrap()),
|
||||||
|
false => String::from(""),
|
||||||
|
},
|
||||||
match .valid_fields.is_empty() {
|
match .valid_fields.is_empty() {
|
||||||
true => "This index does not have configured sortable attributes.".to_string(),
|
true => "This index does not have configured sortable attributes.".to_string(),
|
||||||
false => format!("Available sortable attributes are: `{}{}`.",
|
false => format!("Available sortable attributes are: `{}{}`.",
|
||||||
@ -133,7 +136,12 @@ only composed of alphanumeric characters (a-z A-Z 0-9), hyphens (-) and undersco
|
|||||||
),
|
),
|
||||||
}
|
}
|
||||||
)]
|
)]
|
||||||
InvalidSortableAttribute { field: String, index: String, valid_fields: BTreeSet<String>, hidden_fields: bool },
|
InvalidSortableAttribute {
|
||||||
|
field: String,
|
||||||
|
index_name: Option<String>,
|
||||||
|
valid_fields: BTreeSet<String>,
|
||||||
|
hidden_fields: bool,
|
||||||
|
},
|
||||||
#[error("Attribute `{}` is not facet-searchable. {}",
|
#[error("Attribute `{}` is not facet-searchable. {}",
|
||||||
.field,
|
.field,
|
||||||
match .valid_fields.is_empty() {
|
match .valid_fields.is_empty() {
|
||||||
|
@ -100,7 +100,7 @@ pub mod db_name {
|
|||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Index {
|
pub struct Index {
|
||||||
pub name: String,
|
pub name: Option<String>,
|
||||||
|
|
||||||
/// The LMDB environment which this index is associated with.
|
/// The LMDB environment which this index is associated with.
|
||||||
pub(crate) env: heed::Env,
|
pub(crate) env: heed::Env,
|
||||||
@ -173,7 +173,7 @@ pub struct Index {
|
|||||||
|
|
||||||
impl Index {
|
impl Index {
|
||||||
pub fn new_with_creation_dates<P: AsRef<Path>>(
|
pub fn new_with_creation_dates<P: AsRef<Path>>(
|
||||||
name: &str,
|
name: Option<String>,
|
||||||
mut options: heed::EnvOpenOptions,
|
mut options: heed::EnvOpenOptions,
|
||||||
path: P,
|
path: P,
|
||||||
created_at: OffsetDateTime,
|
created_at: OffsetDateTime,
|
||||||
@ -183,7 +183,7 @@ impl Index {
|
|||||||
|
|
||||||
options.max_dbs(25);
|
options.max_dbs(25);
|
||||||
|
|
||||||
let name = String::from(name);
|
let name = name;
|
||||||
let env = options.open(path)?;
|
let env = options.open(path)?;
|
||||||
let mut wtxn = env.write_txn()?;
|
let mut wtxn = env.write_txn()?;
|
||||||
let main = env.database_options().name(MAIN).create(&mut wtxn)?;
|
let main = env.database_options().name(MAIN).create(&mut wtxn)?;
|
||||||
@ -263,7 +263,11 @@ impl Index {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new<P: AsRef<Path>>(name: &str, options: heed::EnvOpenOptions, path: P) -> Result<Index> {
|
pub fn new<P: AsRef<Path>>(
|
||||||
|
name: Option<String>,
|
||||||
|
options: heed::EnvOpenOptions,
|
||||||
|
path: P,
|
||||||
|
) -> Result<Index> {
|
||||||
let now = OffsetDateTime::now_utc();
|
let now = OffsetDateTime::now_utc();
|
||||||
Self::new_with_creation_dates(name, options, path, now, now)
|
Self::new_with_creation_dates(name, options, path, now, now)
|
||||||
}
|
}
|
||||||
|
@ -706,7 +706,7 @@ fn check_sort_criteria(ctx: &SearchContext, sort_criteria: Option<&Vec<AscDesc>>
|
|||||||
|
|
||||||
return Err(UserError::InvalidSortableAttribute {
|
return Err(UserError::InvalidSortableAttribute {
|
||||||
field: field.to_string(),
|
field: field.to_string(),
|
||||||
index: ctx.index.name.clone(),
|
index_name: ctx.index.name.clone(),
|
||||||
valid_fields,
|
valid_fields,
|
||||||
hidden_fields,
|
hidden_fields,
|
||||||
}
|
}
|
||||||
@ -718,7 +718,7 @@ fn check_sort_criteria(ctx: &SearchContext, sort_criteria: Option<&Vec<AscDesc>>
|
|||||||
|
|
||||||
return Err(UserError::InvalidSortableAttribute {
|
return Err(UserError::InvalidSortableAttribute {
|
||||||
field: "_geo".to_string(),
|
field: "_geo".to_string(),
|
||||||
index: ctx.index.name.clone(),
|
index_name: ctx.index.name.clone(),
|
||||||
valid_fields,
|
valid_fields,
|
||||||
hidden_fields,
|
hidden_fields,
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user