mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-12-04 18:45:46 +01: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
@ -167,7 +167,7 @@ impl IndexMap {
|
||||
///
|
||||
pub fn create(
|
||||
&mut self,
|
||||
name: &str,
|
||||
name: &str,
|
||||
uuid: &Uuid,
|
||||
path: &Path,
|
||||
date: Option<(OffsetDateTime, OffsetDateTime)>,
|
||||
@ -297,7 +297,7 @@ impl IndexMap {
|
||||
/// Create or open an index in the specified path.
|
||||
/// The path *must* exist or an error will be thrown.
|
||||
fn create_or_open_index(
|
||||
name: &str,
|
||||
name: &str,
|
||||
path: &Path,
|
||||
date: Option<(OffsetDateTime, OffsetDateTime)>,
|
||||
enable_mdb_writemap: bool,
|
||||
@ -311,9 +311,15 @@ fn create_or_open_index(
|
||||
}
|
||||
|
||||
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 {
|
||||
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),
|
||||
#[error("Invalid type for filter subexpression: expected: {}, found: {1}.", .0.join(", "))]
|
||||
InvalidFilterExpression(&'static [&'static str], Value),
|
||||
#[error("Attribute `{}` of index `{}` is not sortable. {}",
|
||||
#[error("Attribute `{}`{} is not sortable. {}",
|
||||
.field,
|
||||
.index,
|
||||
match .index_name.is_some() {
|
||||
true => format!(" of index `{}`", index_name.clone().unwrap()),
|
||||
false => String::from(""),
|
||||
},
|
||||
match .valid_fields.is_empty() {
|
||||
true => "This index does not have configured sortable attributes.".to_string(),
|
||||
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. {}",
|
||||
.field,
|
||||
match .valid_fields.is_empty() {
|
||||
|
@ -100,7 +100,7 @@ pub mod db_name {
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Index {
|
||||
pub name: String,
|
||||
pub name: Option<String>,
|
||||
|
||||
/// The LMDB environment which this index is associated with.
|
||||
pub(crate) env: heed::Env,
|
||||
@ -173,7 +173,7 @@ pub struct Index {
|
||||
|
||||
impl Index {
|
||||
pub fn new_with_creation_dates<P: AsRef<Path>>(
|
||||
name: &str,
|
||||
name: Option<String>,
|
||||
mut options: heed::EnvOpenOptions,
|
||||
path: P,
|
||||
created_at: OffsetDateTime,
|
||||
@ -183,8 +183,8 @@ impl Index {
|
||||
|
||||
options.max_dbs(25);
|
||||
|
||||
let name = String::from(name);
|
||||
let env = options.open(path)?;
|
||||
let name = name;
|
||||
let env = options.open(path)?;
|
||||
let mut wtxn = env.write_txn()?;
|
||||
let main = env.database_options().name(MAIN).create(&mut wtxn)?;
|
||||
let word_docids = env.create_database(&mut wtxn, Some(WORD_DOCIDS))?;
|
||||
@ -233,7 +233,7 @@ impl Index {
|
||||
Index::set_creation_dates(&env, main, created_at, updated_at)?;
|
||||
|
||||
Ok(Index {
|
||||
name,
|
||||
name,
|
||||
env,
|
||||
main,
|
||||
external_documents_ids,
|
||||
@ -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();
|
||||
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 {
|
||||
field: field.to_string(),
|
||||
index: ctx.index.name.clone(),
|
||||
index_name: ctx.index.name.clone(),
|
||||
valid_fields,
|
||||
hidden_fields,
|
||||
}
|
||||
@ -718,7 +718,7 @@ fn check_sort_criteria(ctx: &SearchContext, sort_criteria: Option<&Vec<AscDesc>>
|
||||
|
||||
return Err(UserError::InvalidSortableAttribute {
|
||||
field: "_geo".to_string(),
|
||||
index: ctx.index.name.clone(),
|
||||
index_name: ctx.index.name.clone(),
|
||||
valid_fields,
|
||||
hidden_fields,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user