Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Commit

Permalink
Merge pull request #502 from meilisearch/add-typo-fix2
Browse files Browse the repository at this point in the history
v0.26.2 release: includes the typo-tolerance fix
  • Loading branch information
curquiza authored Apr 19, 2022
2 parents a68e3a7 + f750166 commit b0c4789
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cli"
version = "0.26.1"
version = "0.26.2"
edition = "2018"
description = "A CLI to interact with a milli index"

Expand Down
2 changes: 1 addition & 1 deletion helpers/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "helpers"
version = "0.26.1"
version = "0.26.2"
authors = ["Clément Renault <clement@meilisearch.com>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion http-ui/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "http-ui"
description = "The HTTP user interface of the milli search engine"
version = "0.26.1"
version = "0.26.2"
authors = ["Clément Renault <clement@meilisearch.com>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion infos/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "infos"
version = "0.26.1"
version = "0.26.2"
authors = ["Clément Renault <clement@meilisearch.com>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion milli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "milli"
version = "0.26.1"
version = "0.26.2"
authors = ["Kerollmops <clement@meilisearch.com>"]
edition = "2018"

Expand Down
27 changes: 26 additions & 1 deletion milli/src/update/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use super::index_documents::{IndexDocumentsConfig, Transform};
use super::IndexerConfig;
use crate::criterion::Criterion;
use crate::error::UserError;
use crate::index::{DEFAULT_MIN_WORD_LEN_ONE_TYPO, DEFAULT_MIN_WORD_LEN_TWO_TYPOS};
use crate::update::index_documents::IndexDocumentsMethod;
use crate::update::{ClearDocuments, IndexDocuments, UpdateIndexingStep};
use crate::{FieldsIdsMap, Index, Result};
Expand Down Expand Up @@ -46,6 +47,14 @@ impl<T> Setting<T> {
pub const fn is_not_set(&self) -> bool {
matches!(self, Self::NotSet)
}

/// If `Self` is `Reset`, then map self to `Set` with the provided `val`.
pub fn or_reset(self, val: T) -> Self {
match self {
Self::Reset => Self::Set(val),
otherwise => otherwise,
}
}
}

impl<T: Serialize> Serialize for Setting<T> {
Expand Down Expand Up @@ -535,7 +544,9 @@ impl<'a, 't, 'u, 'i> Settings<'a, 't, 'u, 'i> {
}

fn update_min_typo_word_len(&mut self) -> Result<()> {
match (self.min_word_len_one_typo, self.min_word_len_two_typos) {
let one = self.min_word_len_one_typo.or_reset(DEFAULT_MIN_WORD_LEN_ONE_TYPO);
let two = self.min_word_len_two_typos.or_reset(DEFAULT_MIN_WORD_LEN_TWO_TYPOS);
match (one, two) {
(Setting::Set(one), Setting::Set(two)) => {
if one > two {
return Err(UserError::InvalidMinTypoWordLenSetting(one, two).into());
Expand Down Expand Up @@ -1422,6 +1433,20 @@ mod tests {

assert_eq!(index.min_word_len_one_typo(&txn).unwrap(), 8);
assert_eq!(index.min_word_len_two_typos(&txn).unwrap(), 8);

let mut txn = index.write_txn().unwrap();
let mut builder = Settings::new(&mut txn, &index, &config);

builder.reset_min_word_len_one_typo();
builder.reset_min_word_len_two_typos();
builder.execute(|_| ()).unwrap();

txn.commit().unwrap();

let txn = index.read_txn().unwrap();

assert_eq!(index.min_word_len_one_typo(&txn).unwrap(), DEFAULT_MIN_WORD_LEN_ONE_TYPO);
assert_eq!(index.min_word_len_two_typos(&txn).unwrap(), DEFAULT_MIN_WORD_LEN_TWO_TYPOS);
}

#[test]
Expand Down

0 comments on commit b0c4789

Please sign in to comment.