mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-26 23:04:26 +01:00
Merge #1293
1293: stable to master r=curquiza a=MarinPostma replace & close #1239 Co-authored-by: mpostma <postma.marin@protonmail.com> Co-authored-by: marin <postma.marin@protonmail.com> Co-authored-by: Many <legendre.maxime.isn@gmail.com> Co-authored-by: many <maxime@meilisearch.com> Co-authored-by: bors[bot] <26634292+bors[bot]@users.noreply.github.com>
This commit is contained in:
commit
56b4782ee1
@ -14,7 +14,7 @@
|
|||||||
- Fix setting consistency bug (#1128)
|
- Fix setting consistency bug (#1128)
|
||||||
- Fix attributes to retrieve bug (#1131)
|
- Fix attributes to retrieve bug (#1131)
|
||||||
- Increase default payload size (#1147)
|
- Increase default payload size (#1147)
|
||||||
- Improvements to code quality (#1167, #1165, #1126, #1161)
|
- Improvements to code quality (#1167, #1165, #1126, #1151)
|
||||||
|
|
||||||
## v0.17.0 - 2020-11-30
|
## v0.17.0 - 2020-11-30
|
||||||
- Fix corrupted data during placeholder search (#1089)
|
- Fix corrupted data during placeholder search (#1089)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use std::{borrow::Cow, collections::{BTreeMap, BTreeSet}};
|
use std::{borrow::Cow, collections::{BTreeMap, BTreeSet}};
|
||||||
|
|
||||||
use heed::Result as ZResult;
|
use heed::Result as ZResult;
|
||||||
use fst::{set::OpBuilder, SetBuilder};
|
use fst::{SetBuilder, set::OpBuilder};
|
||||||
use sdset::SetBuf;
|
use sdset::SetBuf;
|
||||||
use meilisearch_schema::Schema;
|
use meilisearch_schema::Schema;
|
||||||
use meilisearch_tokenizer::analyzer::{Analyzer, AnalyzerConfig};
|
use meilisearch_tokenizer::analyzer::{Analyzer, AnalyzerConfig};
|
||||||
@ -299,15 +299,22 @@ pub fn apply_synonyms_update(
|
|||||||
.fold(String::new(), |s, t| s + t.text())
|
.fold(String::new(), |s, t| s + t.text())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// normalize synonyms and reorder them creating a BTreeMap
|
||||||
|
let synonyms: BTreeMap<String, Vec<String>> = synonyms.into_iter().map( |(word, alternatives)| {
|
||||||
|
let word = normalize(&analyzer, &word);
|
||||||
|
let alternatives = alternatives.into_iter().map(|text| normalize(&analyzer, &text)).collect();
|
||||||
|
|
||||||
|
(word, alternatives)
|
||||||
|
}).collect();
|
||||||
|
|
||||||
|
// index synonyms,
|
||||||
|
// synyonyms have to be ordered by key before indexation
|
||||||
let mut synonyms_builder = SetBuilder::memory();
|
let mut synonyms_builder = SetBuilder::memory();
|
||||||
synonyms_store.clear(writer)?;
|
synonyms_store.clear(writer)?;
|
||||||
for (word, alternatives) in synonyms {
|
for (word, alternatives) in synonyms {
|
||||||
let word = normalize(&analyzer, &word);
|
|
||||||
|
|
||||||
synonyms_builder.insert(&word)?;
|
synonyms_builder.insert(&word)?;
|
||||||
|
|
||||||
let alternatives = {
|
let alternatives = {
|
||||||
let alternatives = alternatives.iter().map(|text| normalize(&analyzer, &text)).collect();
|
|
||||||
let alternatives = SetBuf::from_dirty(alternatives);
|
let alternatives = SetBuf::from_dirty(alternatives);
|
||||||
let mut alternatives_builder = SetBuilder::memory();
|
let mut alternatives_builder = SetBuilder::memory();
|
||||||
alternatives_builder.extend_iter(alternatives)?;
|
alternatives_builder.extend_iter(alternatives)?;
|
||||||
|
@ -175,7 +175,6 @@ async fn update_multiple_documents(
|
|||||||
.ok_or(meilisearch_core::Error::SchemaMissing)?;
|
.ok_or(meilisearch_core::Error::SchemaMissing)?;
|
||||||
|
|
||||||
match (params.into_inner().primary_key, schema.primary_key()) {
|
match (params.into_inner().primary_key, schema.primary_key()) {
|
||||||
(Some(_), Some(_)) => return Err(meilisearch_schema::Error::PrimaryKeyAlreadyPresent.into()),
|
|
||||||
(Some(key), None) => document_addition.set_primary_key(key),
|
(Some(key), None) => document_addition.set_primary_key(key),
|
||||||
(None, None) => {
|
(None, None) => {
|
||||||
let key = body
|
let key = body
|
||||||
@ -184,7 +183,7 @@ async fn update_multiple_documents(
|
|||||||
.ok_or(meilisearch_core::Error::MissingPrimaryKey)?;
|
.ok_or(meilisearch_core::Error::MissingPrimaryKey)?;
|
||||||
document_addition.set_primary_key(key);
|
document_addition.set_primary_key(key);
|
||||||
}
|
}
|
||||||
(None, Some(_)) => ()
|
_ => ()
|
||||||
}
|
}
|
||||||
|
|
||||||
for document in body.into_inner() {
|
for document in body.into_inner() {
|
||||||
|
@ -171,6 +171,8 @@ async fn write_all_and_update() {
|
|||||||
"synonyms": {
|
"synonyms": {
|
||||||
"road": ["street", "avenue"],
|
"road": ["street", "avenue"],
|
||||||
"street": ["avenue"],
|
"street": ["avenue"],
|
||||||
|
"HP": ["Harry Potter"],
|
||||||
|
"Harry Potter": ["HP"]
|
||||||
},
|
},
|
||||||
"attributesForFaceting": ["title"],
|
"attributesForFaceting": ["title"],
|
||||||
});
|
});
|
||||||
@ -208,6 +210,8 @@ async fn write_all_and_update() {
|
|||||||
"synonyms": {
|
"synonyms": {
|
||||||
"road": ["street", "avenue"],
|
"road": ["street", "avenue"],
|
||||||
"street": ["avenue"],
|
"street": ["avenue"],
|
||||||
|
"hp": ["harry potter"],
|
||||||
|
"harry potter": ["hp"]
|
||||||
},
|
},
|
||||||
"attributesForFaceting": ["title"],
|
"attributesForFaceting": ["title"],
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user