mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-11 23:48:56 +01:00
Change the naming of attributeScale and wordScale into byAttribute and byWord
This commit is contained in:
parent
35e1981488
commit
6425996e36
@ -703,23 +703,23 @@ impl From<RankingRuleView> for Criterion {
|
|||||||
#[serde(deny_unknown_fields, rename_all = "camelCase")]
|
#[serde(deny_unknown_fields, rename_all = "camelCase")]
|
||||||
#[deserr(error = DeserrJsonError<InvalidSettingsProximityPrecision>, rename_all = camelCase, deny_unknown_fields)]
|
#[deserr(error = DeserrJsonError<InvalidSettingsProximityPrecision>, rename_all = camelCase, deny_unknown_fields)]
|
||||||
pub enum ProximityPrecisionView {
|
pub enum ProximityPrecisionView {
|
||||||
WordScale,
|
ByWord,
|
||||||
AttributeScale,
|
ByAttribute,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ProximityPrecision> for ProximityPrecisionView {
|
impl From<ProximityPrecision> for ProximityPrecisionView {
|
||||||
fn from(value: ProximityPrecision) -> Self {
|
fn from(value: ProximityPrecision) -> Self {
|
||||||
match value {
|
match value {
|
||||||
ProximityPrecision::WordScale => ProximityPrecisionView::WordScale,
|
ProximityPrecision::ByWord => ProximityPrecisionView::ByWord,
|
||||||
ProximityPrecision::AttributeScale => ProximityPrecisionView::AttributeScale,
|
ProximityPrecision::ByAttribute => ProximityPrecisionView::ByAttribute,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<ProximityPrecisionView> for ProximityPrecision {
|
impl From<ProximityPrecisionView> for ProximityPrecision {
|
||||||
fn from(value: ProximityPrecisionView) -> Self {
|
fn from(value: ProximityPrecisionView) -> Self {
|
||||||
match value {
|
match value {
|
||||||
ProximityPrecisionView::WordScale => ProximityPrecision::WordScale,
|
ProximityPrecisionView::ByWord => ProximityPrecision::ByWord,
|
||||||
ProximityPrecisionView::AttributeScale => ProximityPrecision::AttributeScale,
|
ProximityPrecisionView::ByAttribute => ProximityPrecision::ByAttribute,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
@ -1877,7 +1877,7 @@ async fn import_dump_v6_containing_experimental_features() {
|
|||||||
"dictionary": [],
|
"dictionary": [],
|
||||||
"synonyms": {},
|
"synonyms": {},
|
||||||
"distinctAttribute": null,
|
"distinctAttribute": null,
|
||||||
"proximityPrecision": "attributeScale",
|
"proximityPrecision": "byAttribute",
|
||||||
"typoTolerance": {
|
"typoTolerance": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"minWordSizeForTypos": {
|
"minWordSizeForTypos": {
|
||||||
|
@ -34,7 +34,7 @@ async fn attribute_scale_search() {
|
|||||||
|
|
||||||
let (response, code) = index
|
let (response, code) = index
|
||||||
.update_settings(json!({
|
.update_settings(json!({
|
||||||
"proximityPrecision": "attributeScale",
|
"proximityPrecision": "byAttribute",
|
||||||
"rankingRules": ["words", "typo", "proximity"],
|
"rankingRules": ["words", "typo", "proximity"],
|
||||||
}))
|
}))
|
||||||
.await;
|
.await;
|
||||||
@ -107,7 +107,7 @@ async fn attribute_scale_phrase_search() {
|
|||||||
|
|
||||||
let (_response, _code) = index
|
let (_response, _code) = index
|
||||||
.update_settings(json!({
|
.update_settings(json!({
|
||||||
"proximityPrecision": "attributeScale",
|
"proximityPrecision": "byAttribute",
|
||||||
"rankingRules": ["words", "typo", "proximity"],
|
"rankingRules": ["words", "typo", "proximity"],
|
||||||
}))
|
}))
|
||||||
.await;
|
.await;
|
||||||
@ -176,7 +176,7 @@ async fn word_scale_set_and_reset() {
|
|||||||
// Set and reset the setting ensuring the swap between the 2 settings is applied.
|
// Set and reset the setting ensuring the swap between the 2 settings is applied.
|
||||||
let (_response, _code) = index
|
let (_response, _code) = index
|
||||||
.update_settings(json!({
|
.update_settings(json!({
|
||||||
"proximityPrecision": "attributeScale",
|
"proximityPrecision": "byAttribute",
|
||||||
"rankingRules": ["words", "typo", "proximity"],
|
"rankingRules": ["words", "typo", "proximity"],
|
||||||
}))
|
}))
|
||||||
.await;
|
.await;
|
||||||
@ -184,7 +184,7 @@ async fn word_scale_set_and_reset() {
|
|||||||
|
|
||||||
let (_response, _code) = index
|
let (_response, _code) = index
|
||||||
.update_settings(json!({
|
.update_settings(json!({
|
||||||
"proximityPrecision": "wordScale",
|
"proximityPrecision": "byWord",
|
||||||
"rankingRules": ["words", "typo", "proximity"],
|
"rankingRules": ["words", "typo", "proximity"],
|
||||||
}))
|
}))
|
||||||
.await;
|
.await;
|
||||||
@ -290,7 +290,7 @@ async fn attribute_scale_default_ranking_rules() {
|
|||||||
|
|
||||||
let (response, code) = index
|
let (response, code) = index
|
||||||
.update_settings(json!({
|
.update_settings(json!({
|
||||||
"proximityPrecision": "attributeScale"
|
"proximityPrecision": "byAttribute"
|
||||||
}))
|
}))
|
||||||
.await;
|
.await;
|
||||||
assert_eq!("202", code.as_str(), "{:?}", response);
|
assert_eq!("202", code.as_str(), "{:?}", response);
|
||||||
|
@ -32,6 +32,6 @@ pub fn path_proximity(path: &[Position]) -> u32 {
|
|||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub enum ProximityPrecision {
|
pub enum ProximityPrecision {
|
||||||
#[default]
|
#[default]
|
||||||
WordScale,
|
ByWord,
|
||||||
AttributeScale,
|
ByAttribute,
|
||||||
}
|
}
|
||||||
|
@ -299,9 +299,9 @@ impl<'ctx> SearchContext<'ctx> {
|
|||||||
proximity: u8,
|
proximity: u8,
|
||||||
) -> Result<Option<RoaringBitmap>> {
|
) -> Result<Option<RoaringBitmap>> {
|
||||||
match self.index.proximity_precision(self.txn)?.unwrap_or_default() {
|
match self.index.proximity_precision(self.txn)?.unwrap_or_default() {
|
||||||
ProximityPrecision::AttributeScale => {
|
ProximityPrecision::ByAttribute => {
|
||||||
// Force proximity to 0 because:
|
// Force proximity to 0 because:
|
||||||
// in AttributeScale, there are only 2 possible distances:
|
// in ByAttribute, there are only 2 possible distances:
|
||||||
// 1. words in same attribute: in that the DB contains (0, word1, word2)
|
// 1. words in same attribute: in that the DB contains (0, word1, word2)
|
||||||
// 2. words in different attributes: no DB entry for these two words.
|
// 2. words in different attributes: no DB entry for these two words.
|
||||||
let proximity = 0;
|
let proximity = 0;
|
||||||
@ -345,8 +345,7 @@ impl<'ctx> SearchContext<'ctx> {
|
|||||||
|
|
||||||
Ok(docids)
|
Ok(docids)
|
||||||
}
|
}
|
||||||
ProximityPrecision::WordScale => {
|
ProximityPrecision::ByWord => DatabaseCache::get_value::<_, _, CboRoaringBitmapCodec>(
|
||||||
DatabaseCache::get_value::<_, _, CboRoaringBitmapCodec>(
|
|
||||||
self.txn,
|
self.txn,
|
||||||
(proximity, word1, word2),
|
(proximity, word1, word2),
|
||||||
&(
|
&(
|
||||||
@ -356,8 +355,7 @@ impl<'ctx> SearchContext<'ctx> {
|
|||||||
),
|
),
|
||||||
&mut self.db_cache.word_pair_proximity_docids,
|
&mut self.db_cache.word_pair_proximity_docids,
|
||||||
self.index.word_pair_proximity_docids.remap_data_type::<Bytes>(),
|
self.index.word_pair_proximity_docids.remap_data_type::<Bytes>(),
|
||||||
)
|
),
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -368,10 +366,10 @@ impl<'ctx> SearchContext<'ctx> {
|
|||||||
proximity: u8,
|
proximity: u8,
|
||||||
) -> Result<Option<u64>> {
|
) -> Result<Option<u64>> {
|
||||||
match self.index.proximity_precision(self.txn)?.unwrap_or_default() {
|
match self.index.proximity_precision(self.txn)?.unwrap_or_default() {
|
||||||
ProximityPrecision::AttributeScale => Ok(self
|
ProximityPrecision::ByAttribute => Ok(self
|
||||||
.get_db_word_pair_proximity_docids(word1, word2, proximity)?
|
.get_db_word_pair_proximity_docids(word1, word2, proximity)?
|
||||||
.map(|d| d.len())),
|
.map(|d| d.len())),
|
||||||
ProximityPrecision::WordScale => {
|
ProximityPrecision::ByWord => {
|
||||||
DatabaseCache::get_value::<_, _, CboRoaringBitmapLenCodec>(
|
DatabaseCache::get_value::<_, _, CboRoaringBitmapLenCodec>(
|
||||||
self.txn,
|
self.txn,
|
||||||
(proximity, word1, word2),
|
(proximity, word1, word2),
|
||||||
@ -394,9 +392,9 @@ impl<'ctx> SearchContext<'ctx> {
|
|||||||
mut proximity: u8,
|
mut proximity: u8,
|
||||||
) -> Result<Option<RoaringBitmap>> {
|
) -> Result<Option<RoaringBitmap>> {
|
||||||
let proximity_precision = self.index.proximity_precision(self.txn)?.unwrap_or_default();
|
let proximity_precision = self.index.proximity_precision(self.txn)?.unwrap_or_default();
|
||||||
if proximity_precision == ProximityPrecision::AttributeScale {
|
if proximity_precision == ProximityPrecision::ByAttribute {
|
||||||
// Force proximity to 0 because:
|
// Force proximity to 0 because:
|
||||||
// in AttributeScale, there are only 2 possible distances:
|
// in ByAttribute, there are only 2 possible distances:
|
||||||
// 1. words in same attribute: in that the DB contains (0, word1, word2)
|
// 1. words in same attribute: in that the DB contains (0, word1, word2)
|
||||||
// 2. words in different attributes: no DB entry for these two words.
|
// 2. words in different attributes: no DB entry for these two words.
|
||||||
proximity = 0;
|
proximity = 0;
|
||||||
@ -408,7 +406,7 @@ impl<'ctx> SearchContext<'ctx> {
|
|||||||
docids.clone()
|
docids.clone()
|
||||||
} else {
|
} else {
|
||||||
let prefix_docids = match proximity_precision {
|
let prefix_docids = match proximity_precision {
|
||||||
ProximityPrecision::AttributeScale => {
|
ProximityPrecision::ByAttribute => {
|
||||||
// Compute the distance at the attribute level and store it in the cache.
|
// Compute the distance at the attribute level and store it in the cache.
|
||||||
let fids = if let Some(fids) = self.index.searchable_fields_ids(self.txn)? {
|
let fids = if let Some(fids) = self.index.searchable_fields_ids(self.txn)? {
|
||||||
fids
|
fids
|
||||||
@ -429,7 +427,7 @@ impl<'ctx> SearchContext<'ctx> {
|
|||||||
}
|
}
|
||||||
prefix_docids
|
prefix_docids
|
||||||
}
|
}
|
||||||
ProximityPrecision::WordScale => {
|
ProximityPrecision::ByWord => {
|
||||||
// compute docids using prefix iter and store the result in the cache.
|
// compute docids using prefix iter and store the result in the cache.
|
||||||
let key = U8StrStrCodec::bytes_encode(&(
|
let key = U8StrStrCodec::bytes_encode(&(
|
||||||
proximity,
|
proximity,
|
||||||
|
@ -152,7 +152,7 @@ pub(crate) fn data_from_obkv_documents(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if proximity_precision == ProximityPrecision::WordScale {
|
if proximity_precision == ProximityPrecision::ByWord {
|
||||||
spawn_extraction_task::<_, _, Vec<grenad::Reader<BufReader<File>>>>(
|
spawn_extraction_task::<_, _, Vec<grenad::Reader<BufReader<File>>>>(
|
||||||
docid_word_positions_chunks.clone(),
|
docid_word_positions_chunks.clone(),
|
||||||
indexer,
|
indexer,
|
||||||
|
Loading…
Reference in New Issue
Block a user