mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-22 18:17:39 +08:00
Tests pass
This commit is contained in:
parent
61bd2fb7a9
commit
806e5b6899
@ -20,22 +20,27 @@ static DOCUMENTS: Lazy<Value> = Lazy::new(|| {
|
|||||||
{
|
{
|
||||||
"title": "Shazam!",
|
"title": "Shazam!",
|
||||||
"id": "287947",
|
"id": "287947",
|
||||||
|
"_vectors": { "manual": [1, 2, 3]},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "Captain Marvel",
|
"title": "Captain Marvel",
|
||||||
"id": "299537",
|
"id": "299537",
|
||||||
|
"_vectors": { "manual": [1, 2, 54] },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "Escape Room",
|
"title": "Escape Room",
|
||||||
"id": "522681",
|
"id": "522681",
|
||||||
|
"_vectors": { "manual": [10, -23, 32] },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "How to Train Your Dragon: The Hidden World",
|
"title": "How to Train Your Dragon: The Hidden World",
|
||||||
"id": "166428",
|
"id": "166428",
|
||||||
|
"_vectors": { "manual": [-100, 231, 32] },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "Gläss",
|
"title": "Gläss",
|
||||||
"id": "450465",
|
"id": "450465",
|
||||||
|
"_vectors": { "manual": [-100, 340, 90] },
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
});
|
});
|
||||||
@ -57,6 +62,7 @@ static NESTED_DOCUMENTS: Lazy<Value> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
"cattos": "pésti",
|
"cattos": "pésti",
|
||||||
|
"_vectors": { "manual": [1, 2, 3]},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 654,
|
"id": 654,
|
||||||
@ -69,12 +75,14 @@ static NESTED_DOCUMENTS: Lazy<Value> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
"cattos": ["simba", "pestiféré"],
|
"cattos": ["simba", "pestiféré"],
|
||||||
|
"_vectors": { "manual": [1, 2, 54] },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 750,
|
"id": 750,
|
||||||
"father": "romain",
|
"father": "romain",
|
||||||
"mother": "michelle",
|
"mother": "michelle",
|
||||||
"cattos": ["enigma"],
|
"cattos": ["enigma"],
|
||||||
|
"_vectors": { "manual": [10, 23, 32] },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 951,
|
"id": 951,
|
||||||
@ -91,6 +99,7 @@ static NESTED_DOCUMENTS: Lazy<Value> = Lazy::new(|| {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
"cattos": ["moumoute", "gomez"],
|
"cattos": ["moumoute", "gomez"],
|
||||||
|
"_vectors": { "manual": [10, 23, 32] },
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
});
|
});
|
||||||
@ -802,6 +811,13 @@ async fn experimental_feature_score_details() {
|
|||||||
{
|
{
|
||||||
"title": "How to Train Your Dragon: The Hidden World",
|
"title": "How to Train Your Dragon: The Hidden World",
|
||||||
"id": "166428",
|
"id": "166428",
|
||||||
|
"_vectors": {
|
||||||
|
"manual": [
|
||||||
|
-100,
|
||||||
|
231,
|
||||||
|
32
|
||||||
|
]
|
||||||
|
},
|
||||||
"_rankingScoreDetails": {
|
"_rankingScoreDetails": {
|
||||||
"words": {
|
"words": {
|
||||||
"order": 0,
|
"order": 0,
|
||||||
@ -823,7 +839,7 @@ async fn experimental_feature_score_details() {
|
|||||||
"order": 3,
|
"order": 3,
|
||||||
"attributeRankingOrderScore": 1.0,
|
"attributeRankingOrderScore": 1.0,
|
||||||
"queryWordDistanceScore": 0.8095238095238095,
|
"queryWordDistanceScore": 0.8095238095238095,
|
||||||
"score": 0.9365079365079364
|
"score": 0.9727891156462584
|
||||||
},
|
},
|
||||||
"exactness": {
|
"exactness": {
|
||||||
"order": 4,
|
"order": 4,
|
||||||
@ -870,34 +886,89 @@ async fn experimental_feature_vector_store() {
|
|||||||
meili_snap::snapshot!(code, @"200 OK");
|
meili_snap::snapshot!(code, @"200 OK");
|
||||||
meili_snap::snapshot!(response["vectorStore"], @"true");
|
meili_snap::snapshot!(response["vectorStore"], @"true");
|
||||||
|
|
||||||
|
let (response, code) = index
|
||||||
|
.update_settings(json!({"embedders": {
|
||||||
|
"manual": {
|
||||||
|
"source": {
|
||||||
|
"userProvided": {"dimensions": 3}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}))
|
||||||
|
.await;
|
||||||
|
|
||||||
|
meili_snap::snapshot!(code, @"202 Accepted");
|
||||||
|
let response = index.wait_task(response.uid()).await;
|
||||||
|
|
||||||
|
meili_snap::snapshot!(meili_snap::json_string!(response["status"]), @"\"succeeded\"");
|
||||||
|
|
||||||
let (response, code) = index
|
let (response, code) = index
|
||||||
.search_post(json!({
|
.search_post(json!({
|
||||||
"vector": [1.0, 2.0, 3.0],
|
"vector": [1.0, 2.0, 3.0],
|
||||||
}))
|
}))
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
meili_snap::snapshot!(code, @"200 OK");
|
meili_snap::snapshot!(code, @"200 OK");
|
||||||
// vector search returns all documents that don't have vectors in the last bucket, like all sorts
|
// vector search returns all documents that don't have vectors in the last bucket, like all sorts
|
||||||
meili_snap::snapshot!(meili_snap::json_string!(response["hits"]), @r###"
|
meili_snap::snapshot!(meili_snap::json_string!(response["hits"]), @r###"
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"title": "Shazam!",
|
"title": "Shazam!",
|
||||||
"id": "287947"
|
"id": "287947",
|
||||||
|
"_vectors": {
|
||||||
|
"manual": [
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
3
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"_semanticScore": 1.0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "Captain Marvel",
|
"title": "Captain Marvel",
|
||||||
"id": "299537"
|
"id": "299537",
|
||||||
},
|
"_vectors": {
|
||||||
{
|
"manual": [
|
||||||
"title": "Escape Room",
|
1,
|
||||||
"id": "522681"
|
2,
|
||||||
},
|
54
|
||||||
{
|
]
|
||||||
"title": "How to Train Your Dragon: The Hidden World",
|
},
|
||||||
"id": "166428"
|
"_semanticScore": 0.9129112
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "Gläss",
|
"title": "Gläss",
|
||||||
"id": "450465"
|
"id": "450465",
|
||||||
|
"_vectors": {
|
||||||
|
"manual": [
|
||||||
|
-100,
|
||||||
|
340,
|
||||||
|
90
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"_semanticScore": 0.8106413
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "How to Train Your Dragon: The Hidden World",
|
||||||
|
"id": "166428",
|
||||||
|
"_vectors": {
|
||||||
|
"manual": [
|
||||||
|
-100,
|
||||||
|
231,
|
||||||
|
32
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"_semanticScore": 0.74120104
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Escape Room",
|
||||||
|
"id": "522681",
|
||||||
|
"_vectors": {
|
||||||
|
"manual": [
|
||||||
|
10,
|
||||||
|
-23,
|
||||||
|
32
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
"###);
|
"###);
|
||||||
@ -1150,7 +1221,14 @@ async fn simple_search_with_strange_synonyms() {
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"title": "How to Train Your Dragon: The Hidden World",
|
"title": "How to Train Your Dragon: The Hidden World",
|
||||||
"id": "166428"
|
"id": "166428",
|
||||||
|
"_vectors": {
|
||||||
|
"manual": [
|
||||||
|
-100,
|
||||||
|
231,
|
||||||
|
32
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
"###);
|
"###);
|
||||||
@ -1164,7 +1242,14 @@ async fn simple_search_with_strange_synonyms() {
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"title": "How to Train Your Dragon: The Hidden World",
|
"title": "How to Train Your Dragon: The Hidden World",
|
||||||
"id": "166428"
|
"id": "166428",
|
||||||
|
"_vectors": {
|
||||||
|
"manual": [
|
||||||
|
-100,
|
||||||
|
231,
|
||||||
|
32
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
"###);
|
"###);
|
||||||
@ -1178,7 +1263,14 @@ async fn simple_search_with_strange_synonyms() {
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"title": "How to Train Your Dragon: The Hidden World",
|
"title": "How to Train Your Dragon: The Hidden World",
|
||||||
"id": "166428"
|
"id": "166428",
|
||||||
|
"_vectors": {
|
||||||
|
"manual": [
|
||||||
|
-100,
|
||||||
|
231,
|
||||||
|
32
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
"###);
|
"###);
|
||||||
|
@ -72,7 +72,14 @@ async fn simple_search_single_index() {
|
|||||||
"hits": [
|
"hits": [
|
||||||
{
|
{
|
||||||
"title": "Gläss",
|
"title": "Gläss",
|
||||||
"id": "450465"
|
"id": "450465",
|
||||||
|
"_vectors": {
|
||||||
|
"manual": [
|
||||||
|
-100,
|
||||||
|
340,
|
||||||
|
90
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"query": "glass",
|
"query": "glass",
|
||||||
@ -86,7 +93,14 @@ async fn simple_search_single_index() {
|
|||||||
"hits": [
|
"hits": [
|
||||||
{
|
{
|
||||||
"title": "Captain Marvel",
|
"title": "Captain Marvel",
|
||||||
"id": "299537"
|
"id": "299537",
|
||||||
|
"_vectors": {
|
||||||
|
"manual": [
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
54
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"query": "captain",
|
"query": "captain",
|
||||||
@ -177,7 +191,14 @@ async fn simple_search_two_indexes() {
|
|||||||
"hits": [
|
"hits": [
|
||||||
{
|
{
|
||||||
"title": "Gläss",
|
"title": "Gläss",
|
||||||
"id": "450465"
|
"id": "450465",
|
||||||
|
"_vectors": {
|
||||||
|
"manual": [
|
||||||
|
-100,
|
||||||
|
340,
|
||||||
|
90
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"query": "glass",
|
"query": "glass",
|
||||||
@ -203,7 +224,14 @@ async fn simple_search_two_indexes() {
|
|||||||
"age": 4
|
"age": 4
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"cattos": "pésti"
|
"cattos": "pésti",
|
||||||
|
"_vectors": {
|
||||||
|
"manual": [
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
3
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 654,
|
"id": 654,
|
||||||
@ -218,7 +246,14 @@ async fn simple_search_two_indexes() {
|
|||||||
"cattos": [
|
"cattos": [
|
||||||
"simba",
|
"simba",
|
||||||
"pestiféré"
|
"pestiféré"
|
||||||
]
|
],
|
||||||
|
"_vectors": {
|
||||||
|
"manual": [
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
54
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"query": "pésti",
|
"query": "pésti",
|
||||||
|
@ -27,8 +27,11 @@ impl<Q: RankingRuleQueryTrait> VectorSort<Q> {
|
|||||||
distribution_shift: Option<DistributionShift>,
|
distribution_shift: Option<DistributionShift>,
|
||||||
embedder_name: &str,
|
embedder_name: &str,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
/// FIXME: unwrap
|
let embedder_index = ctx
|
||||||
let embedder_index = ctx.index.embedder_category_id.get(ctx.txn, embedder_name)?.unwrap();
|
.index
|
||||||
|
.embedder_category_id
|
||||||
|
.get(ctx.txn, embedder_name)?
|
||||||
|
.ok_or_else(|| crate::UserError::InvalidEmbedder(embedder_name.to_owned()))?;
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
query: None,
|
query: None,
|
||||||
|
@ -750,6 +750,8 @@ fn execute_word_prefix_docids(
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use big_s::S;
|
use big_s::S;
|
||||||
use fst::IntoStreamer;
|
use fst::IntoStreamer;
|
||||||
use heed::RwTxn;
|
use heed::RwTxn;
|
||||||
@ -759,6 +761,7 @@ mod tests {
|
|||||||
use crate::documents::documents_batch_reader_from_objects;
|
use crate::documents::documents_batch_reader_from_objects;
|
||||||
use crate::index::tests::TempIndex;
|
use crate::index::tests::TempIndex;
|
||||||
use crate::search::TermsMatchingStrategy;
|
use crate::search::TermsMatchingStrategy;
|
||||||
|
use crate::update::Setting;
|
||||||
use crate::{db_snap, Filter, Search};
|
use crate::{db_snap, Filter, Search};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -2550,13 +2553,34 @@ mod tests {
|
|||||||
/// Vectors must be of the same length.
|
/// Vectors must be of the same length.
|
||||||
#[test]
|
#[test]
|
||||||
fn test_multiple_vectors() {
|
fn test_multiple_vectors() {
|
||||||
|
use crate::vector::settings::{EmbedderSettings, EmbeddingSettings};
|
||||||
let index = TempIndex::new();
|
let index = TempIndex::new();
|
||||||
|
|
||||||
index.add_documents(documents!([{"id": 0, "_vectors": [[0, 1, 2], [3, 4, 5]] }])).unwrap();
|
index
|
||||||
index.add_documents(documents!([{"id": 1, "_vectors": [6, 7, 8] }])).unwrap();
|
.update_settings(|settings| {
|
||||||
|
let mut embedders = BTreeMap::default();
|
||||||
|
embedders.insert(
|
||||||
|
"manual".to_string(),
|
||||||
|
Setting::Set(EmbeddingSettings {
|
||||||
|
embedder_options: Setting::Set(EmbedderSettings::UserProvided(
|
||||||
|
crate::vector::settings::UserProvidedSettings { dimensions: 3 },
|
||||||
|
)),
|
||||||
|
document_template: Setting::NotSet,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
settings.set_embedder_settings(embedders);
|
||||||
|
})
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
index
|
index
|
||||||
.add_documents(
|
.add_documents(
|
||||||
documents!([{"id": 2, "_vectors": [[9, 10, 11], [12, 13, 14], [15, 16, 17]] }]),
|
documents!([{"id": 0, "_vectors": { "manual": [[0, 1, 2], [3, 4, 5]] } }]),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
index.add_documents(documents!([{"id": 1, "_vectors": { "manual": [6, 7, 8] }}])).unwrap();
|
||||||
|
index
|
||||||
|
.add_documents(
|
||||||
|
documents!([{"id": 2, "_vectors": { "manual": [[9, 10, 11], [12, 13, 14], [15, 16, 17]] }}]),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user