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

Commit

Permalink
Merge #698
Browse files Browse the repository at this point in the history
698: Fix soft deleted bug settings r=curquiza a=Kerollmops

This PR is a cherry-pick of #690 and bumps the crates version to v0.33.5.

Co-authored-by: Kerollmops <[email protected]>
  • Loading branch information
bors[bot] and Kerollmops authored Nov 14, 2022
2 parents 4fc6331 + d3be7cd commit cbdcf5e
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 11 deletions.
2 changes: 1 addition & 1 deletion benchmarks/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "benchmarks"
version = "0.33.4"
version = "0.33.5"
edition = "2018"
publish = false

Expand Down
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.33.4"
version = "0.33.5"
edition = "2018"
description = "A CLI to interact with a milli index"
publish = false
Expand Down
2 changes: 1 addition & 1 deletion filter-parser/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "filter-parser"
version = "0.33.4"
version = "0.33.5"
edition = "2021"
description = "The parser for the Meilisearch filter syntax"
publish = false
Expand Down
2 changes: 1 addition & 1 deletion flatten-serde-json/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "flatten-serde-json"
version = "0.33.4"
version = "0.33.5"
edition = "2021"
description = "Flatten serde-json objects like elastic search"
readme = "README.md"
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.33.4"
version = "0.33.5"
authors = ["Clément Renault <[email protected]>"]
edition = "2018"
description = "A small tool to do operations on the database"
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.33.4"
version = "0.33.5"
authors = ["Clément Renault <[email protected]>"]
edition = "2018"
publish = false
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.33.4"
version = "0.33.5"
authors = ["Clément Renault <[email protected]>"]
edition = "2018"
publish = false
Expand Down
2 changes: 1 addition & 1 deletion json-depth-checker/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "json-depth-checker"
version = "0.33.4"
version = "0.33.5"
edition = "2021"
description = "A library that indicates if a JSON must be flattened"
publish = false
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.33.4"
version = "0.33.5"
authors = ["Kerollmops <[email protected]>"]
edition = "2018"

Expand Down
3 changes: 1 addition & 2 deletions milli/src/update/index_documents/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -571,9 +571,8 @@ impl<'a, 'i> Transform<'a, 'i> {
);

let mut obkv_buffer = Vec::new();
for result in self.index.documents.iter(wtxn)? {
for result in self.index.all_documents(wtxn)? {
let (docid, obkv) = result?;
let docid = docid.get();

obkv_buffer.clear();
let mut obkv_writer = obkv::KvWriter::<_, FieldId>::new(&mut obkv_buffer);
Expand Down
31 changes: 31 additions & 0 deletions milli/src/update/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,7 @@ mod tests {
use super::*;
use crate::error::Error;
use crate::index::tests::TempIndex;
use crate::update::DeleteDocuments;
use crate::{Criterion, Filter, SearchResult};

#[test]
Expand Down Expand Up @@ -1489,4 +1490,34 @@ mod tests {
})
.unwrap();
}

#[test]
fn settings_must_ignore_soft_deleted() {
use serde_json::json;

let index = TempIndex::new();

let mut docs = vec![];
for i in 0..10 {
docs.push(json!({ "id": i, "title": format!("{:x}", i) }));
}
index.add_documents(documents! { docs }).unwrap();

let mut wtxn = index.write_txn().unwrap();
let mut builder = DeleteDocuments::new(&mut wtxn, &index).unwrap();
(0..5).for_each(|id| drop(builder.delete_external_id(&id.to_string())));
builder.execute().unwrap();

index
.update_settings_using_wtxn(&mut wtxn, |settings| {
settings.set_searchable_fields(vec!["id".to_string()]);
})
.unwrap();
wtxn.commit().unwrap();

let rtxn = index.write_txn().unwrap();
let docs: StdResult<Vec<_>, _> = index.all_documents(&rtxn).unwrap().collect();
let docs = docs.unwrap();
assert_eq!(docs.len(), 5);
}
}

0 comments on commit cbdcf5e

Please sign in to comment.