mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 20:37:15 +02:00
Merge #4804
4804: Implements the experimental contains filter operator r=irevoire a=irevoire # Pull Request Related PRD: (private link) https://www.notion.so/meilisearch/Contains-Like-Filter-Operator-0d8ad53c6761466f913432eb1d843f1e Public usage page: https://meilisearch.notion.site/Contains-filter-operator-usage-3e7421b0aacf45f48ab09abe259a1de6 ## Related issue Fixes https://github.com/meilisearch/meilisearch/issues/3613 ## What does this PR do? - Extract the contains operator from this PR: https://github.com/meilisearch/meilisearch/pull/3751 - Gate it behind a feature flag - Add tests Co-authored-by: Tamo <tamo@meilisearch.com>
This commit is contained in:
commit
ea73615abf
34 changed files with 487 additions and 121 deletions
|
@ -2140,6 +2140,47 @@ pub(crate) mod tests {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_contains() {
|
||||
let index = TempIndex::new();
|
||||
|
||||
index
|
||||
.update_settings(|settings| {
|
||||
settings.set_filterable_fields(hashset! { S("doggo") });
|
||||
})
|
||||
.unwrap();
|
||||
index
|
||||
.add_documents(documents!([
|
||||
{ "id": 0, "doggo": "kefir" },
|
||||
{ "id": 1, "doggo": "kefirounet" },
|
||||
{ "id": 2, "doggo": "kefkef" },
|
||||
{ "id": 3, "doggo": "fifir" },
|
||||
{ "id": 4, "doggo": "boubou" },
|
||||
{ "id": 5 },
|
||||
]))
|
||||
.unwrap();
|
||||
|
||||
let rtxn = index.read_txn().unwrap();
|
||||
let mut search = index.search(&rtxn);
|
||||
let search_result = search
|
||||
.filter(Filter::from_str("doggo CONTAINS kefir").unwrap().unwrap())
|
||||
.execute()
|
||||
.unwrap();
|
||||
insta::assert_debug_snapshot!(search_result.candidates, @"RoaringBitmap<[0, 1]>");
|
||||
let mut search = index.search(&rtxn);
|
||||
let search_result = search
|
||||
.filter(Filter::from_str("doggo CONTAINS KEF").unwrap().unwrap())
|
||||
.execute()
|
||||
.unwrap();
|
||||
insta::assert_debug_snapshot!(search_result.candidates, @"RoaringBitmap<[0, 1, 2]>");
|
||||
let mut search = index.search(&rtxn);
|
||||
let search_result = search
|
||||
.filter(Filter::from_str("doggo NOT CONTAINS fir").unwrap().unwrap())
|
||||
.execute()
|
||||
.unwrap();
|
||||
insta::assert_debug_snapshot!(search_result.candidates, @"RoaringBitmap<[2, 4, 5]>");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn replace_documents_external_ids_and_soft_deletion_check() {
|
||||
use big_s::S;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue