mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-03 11:57:07 +02:00
Merge #4888
4888: bring back v1.10.0 into main r=Kerollmops a=ManyTheFish Co-authored-by: Louis Dureuil <louis@meilisearch.com> Co-authored-by: meili-bors[bot] <89034592+meili-bors[bot]@users.noreply.github.com> Co-authored-by: Tamo <tamo@meilisearch.com> Co-authored-by: ManyTheFish <many@meilisearch.com>
This commit is contained in:
commit
9a756cf2c5
27 changed files with 2618 additions and 99 deletions
|
@ -72,6 +72,19 @@ fn on_panic(info: &std::panic::PanicInfo) {
|
|||
|
||||
#[actix_web::main]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
try_main().await.inspect_err(|error| {
|
||||
tracing::error!(%error);
|
||||
let mut current = error.source();
|
||||
let mut depth = 0;
|
||||
while let Some(source) = current {
|
||||
tracing::info!(%source, depth, "Error caused by");
|
||||
current = source.source();
|
||||
depth += 1;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async fn try_main() -> anyhow::Result<()> {
|
||||
let (opt, config_read_from) = Opt::try_build()?;
|
||||
|
||||
std::panic::set_hook(Box::new(on_panic));
|
||||
|
|
|
@ -682,6 +682,7 @@ generate_configure!(
|
|||
filterable_attributes,
|
||||
sortable_attributes,
|
||||
displayed_attributes,
|
||||
localized_attributes,
|
||||
searchable_attributes,
|
||||
distinct_attribute,
|
||||
proximity_precision,
|
||||
|
|
|
@ -1369,12 +1369,18 @@ pub fn perform_facet_search(
|
|||
None => TimeBudget::default(),
|
||||
};
|
||||
|
||||
// In the faceted search context, we want to use the intersection between the locales provided by the user
|
||||
// and the locales of the facet string.
|
||||
// If the facet string is not localized, we **ignore** the locales provided by the user because the facet data has no locale.
|
||||
// If the user does not provide locales, we use the locales of the facet string.
|
||||
let localized_attributes = index.localized_attributes_rules(&rtxn)?.unwrap_or_default();
|
||||
let locales = locales.or_else(|| {
|
||||
localized_attributes
|
||||
let localized_attributes_locales =
|
||||
localized_attributes.into_iter().find(|attr| attr.match_str(&facet_name));
|
||||
let locales = localized_attributes_locales.map(|attr| {
|
||||
attr.locales
|
||||
.into_iter()
|
||||
.find(|attr| attr.match_str(&facet_name))
|
||||
.map(|attr| attr.locales)
|
||||
.filter(|locale| locales.as_ref().map_or(true, |locales| locales.contains(locale)))
|
||||
.collect()
|
||||
});
|
||||
|
||||
let (search, _, _, _) =
|
||||
|
|
|
@ -386,12 +386,39 @@ async fn force_locales() {
|
|||
|response, code| {
|
||||
snapshot!(response, @r###"
|
||||
{
|
||||
"hits": [],
|
||||
"hits": [
|
||||
{
|
||||
"name_zh": "进击的巨人",
|
||||
"author_zh": "諫山創",
|
||||
"description_zh": "进击的巨人是日本的漫画系列,由諫山 創作画。",
|
||||
"id": 853,
|
||||
"_vectors": {
|
||||
"manual": [
|
||||
1.0,
|
||||
2.0,
|
||||
3.0
|
||||
]
|
||||
},
|
||||
"_formatted": {
|
||||
"name_zh": "<em>进</em><em>击</em><em>的</em><em>巨人</em>",
|
||||
"author_zh": "諫山創",
|
||||
"description_zh": "<em>进</em><em>击</em><em>的</em><em>巨人</em>是日本的漫画系列,由諫山 創作画。",
|
||||
"id": "853",
|
||||
"_vectors": {
|
||||
"manual": [
|
||||
"1.0",
|
||||
"2.0",
|
||||
"3.0"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"query": "\"进击的巨人\"",
|
||||
"processingTimeMs": "[duration]",
|
||||
"limit": 20,
|
||||
"offset": 0,
|
||||
"estimatedTotalHits": 0
|
||||
"estimatedTotalHits": 1
|
||||
}
|
||||
"###);
|
||||
snapshot!(code, @"200 OK");
|
||||
|
@ -483,12 +510,39 @@ async fn force_locales_with_pattern() {
|
|||
|response, code| {
|
||||
snapshot!(response, @r###"
|
||||
{
|
||||
"hits": [],
|
||||
"hits": [
|
||||
{
|
||||
"name_zh": "进击的巨人",
|
||||
"author_zh": "諫山創",
|
||||
"description_zh": "进击的巨人是日本的漫画系列,由諫山 創作画。",
|
||||
"id": 853,
|
||||
"_vectors": {
|
||||
"manual": [
|
||||
1.0,
|
||||
2.0,
|
||||
3.0
|
||||
]
|
||||
},
|
||||
"_formatted": {
|
||||
"name_zh": "<em>进</em><em>击</em><em>的</em><em>巨人</em>",
|
||||
"author_zh": "諫山創",
|
||||
"description_zh": "<em>进</em><em>击</em><em>的</em><em>巨人</em>是日本的漫画系列,由諫山 創作画。",
|
||||
"id": "853",
|
||||
"_vectors": {
|
||||
"manual": [
|
||||
"1.0",
|
||||
"2.0",
|
||||
"3.0"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"query": "\"进击的巨人\"",
|
||||
"processingTimeMs": "[duration]",
|
||||
"limit": 20,
|
||||
"offset": 0,
|
||||
"estimatedTotalHits": 0
|
||||
"estimatedTotalHits": 1
|
||||
}
|
||||
"###);
|
||||
snapshot!(code, @"200 OK");
|
||||
|
@ -761,6 +815,275 @@ async fn force_different_locales_with_pattern() {
|
|||
.await;
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn auto_infer_locales_at_search_with_attributes_to_search_on() {
|
||||
let server = Server::new().await;
|
||||
|
||||
let index = server.index("test");
|
||||
let documents = DOCUMENTS.clone();
|
||||
let (response, _) = index
|
||||
.update_settings(
|
||||
json!({
|
||||
"searchableAttributes": ["name_en", "name_ja", "name_zh", "author_en", "author_ja", "author_zh", "description_en", "description_ja", "description_zh"],
|
||||
"localizedAttributes": [
|
||||
// force japanese
|
||||
{"attributePatterns": ["*_zh"], "locales": ["jpn"]},
|
||||
// force chinese
|
||||
{"attributePatterns": ["*_ja"], "locales": ["cmn"]},
|
||||
// any language
|
||||
{"attributePatterns": ["*_en"], "locales": []}
|
||||
]
|
||||
}),
|
||||
)
|
||||
.await;
|
||||
snapshot!(response, @r###"
|
||||
{
|
||||
"taskUid": 0,
|
||||
"indexUid": "test",
|
||||
"status": "enqueued",
|
||||
"type": "settingsUpdate",
|
||||
"enqueuedAt": "[date]"
|
||||
}
|
||||
"###);
|
||||
index.add_documents(documents, None).await;
|
||||
index.wait_task(1).await;
|
||||
|
||||
// auto infer any language
|
||||
index
|
||||
.search(
|
||||
json!({"q": "\"进击的巨人\"", "attributesToHighlight": ["*"]}),
|
||||
|response, code| {
|
||||
snapshot!(response, @r###"
|
||||
{
|
||||
"hits": [],
|
||||
"query": "\"进击的巨人\"",
|
||||
"processingTimeMs": "[duration]",
|
||||
"limit": 20,
|
||||
"offset": 0,
|
||||
"estimatedTotalHits": 0
|
||||
}
|
||||
"###);
|
||||
snapshot!(code, @"200 OK");
|
||||
},
|
||||
)
|
||||
.await;
|
||||
|
||||
// should infer chinese
|
||||
index
|
||||
.search(
|
||||
json!({"q": "\"进击的巨人\"", "attributesToHighlight": ["*"], "attributesToSearchOn": ["name_zh", "description_zh"]}),
|
||||
|response, code| {
|
||||
snapshot!(response, @r###"
|
||||
{
|
||||
"hits": [
|
||||
{
|
||||
"name_zh": "进击的巨人",
|
||||
"author_zh": "諫山創",
|
||||
"description_zh": "进击的巨人是日本的漫画系列,由諫山 創作画。",
|
||||
"id": 853,
|
||||
"_vectors": {
|
||||
"manual": [
|
||||
1.0,
|
||||
2.0,
|
||||
3.0
|
||||
]
|
||||
},
|
||||
"_formatted": {
|
||||
"name_zh": "<em>进</em><em>击</em><em>的</em><em>巨人</em>",
|
||||
"author_zh": "諫山創",
|
||||
"description_zh": "<em>进</em><em>击</em><em>的</em><em>巨人</em>是日本的漫画系列,由諫山 創作画。",
|
||||
"id": "853",
|
||||
"_vectors": {
|
||||
"manual": [
|
||||
"1.0",
|
||||
"2.0",
|
||||
"3.0"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"query": "\"进击的巨人\"",
|
||||
"processingTimeMs": "[duration]",
|
||||
"limit": 20,
|
||||
"offset": 0,
|
||||
"estimatedTotalHits": 1
|
||||
}
|
||||
"###);
|
||||
snapshot!(code, @"200 OK");
|
||||
},
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn auto_infer_locales_at_search() {
|
||||
let server = Server::new().await;
|
||||
|
||||
let index = server.index("test");
|
||||
let documents = DOCUMENTS.clone();
|
||||
let (response, _) = index
|
||||
.update_settings(
|
||||
json!({
|
||||
"searchableAttributes": ["name_en", "name_ja", "name_zh", "author_en", "author_ja", "author_zh", "description_en", "description_ja", "description_zh"],
|
||||
"localizedAttributes": [
|
||||
// force japanese
|
||||
{"attributePatterns": ["*"], "locales": ["jpn"]},
|
||||
]
|
||||
}),
|
||||
)
|
||||
.await;
|
||||
snapshot!(response, @r###"
|
||||
{
|
||||
"taskUid": 0,
|
||||
"indexUid": "test",
|
||||
"status": "enqueued",
|
||||
"type": "settingsUpdate",
|
||||
"enqueuedAt": "[date]"
|
||||
}
|
||||
"###);
|
||||
index.add_documents(documents, None).await;
|
||||
index.wait_task(1).await;
|
||||
|
||||
index
|
||||
.search(
|
||||
json!({"q": "\"进击的巨人\"", "attributesToHighlight": ["*"]}),
|
||||
|response, code| {
|
||||
snapshot!(response, @r###"
|
||||
{
|
||||
"hits": [
|
||||
{
|
||||
"name_zh": "进击的巨人",
|
||||
"author_zh": "諫山創",
|
||||
"description_zh": "进击的巨人是日本的漫画系列,由諫山 創作画。",
|
||||
"id": 853,
|
||||
"_vectors": {
|
||||
"manual": [
|
||||
1.0,
|
||||
2.0,
|
||||
3.0
|
||||
]
|
||||
},
|
||||
"_formatted": {
|
||||
"name_zh": "<em>进</em><em>击</em><em>的</em><em>巨人</em>",
|
||||
"author_zh": "諫山創",
|
||||
"description_zh": "<em>进</em><em>击</em><em>的</em><em>巨人</em>是日本的漫画系列,由諫山 創作画。",
|
||||
"id": "853",
|
||||
"_vectors": {
|
||||
"manual": [
|
||||
"1.0",
|
||||
"2.0",
|
||||
"3.0"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"query": "\"进击的巨人\"",
|
||||
"processingTimeMs": "[duration]",
|
||||
"limit": 20,
|
||||
"offset": 0,
|
||||
"estimatedTotalHits": 1
|
||||
}
|
||||
"###);
|
||||
snapshot!(code, @"200 OK");
|
||||
},
|
||||
)
|
||||
.await;
|
||||
|
||||
index
|
||||
.search(
|
||||
json!({"q": "\"进击的巨人\"", "attributesToHighlight": ["*"]}),
|
||||
|response, code| {
|
||||
snapshot!(response, @r###"
|
||||
{
|
||||
"hits": [
|
||||
{
|
||||
"name_zh": "进击的巨人",
|
||||
"author_zh": "諫山創",
|
||||
"description_zh": "进击的巨人是日本的漫画系列,由諫山 創作画。",
|
||||
"id": 853,
|
||||
"_vectors": {
|
||||
"manual": [
|
||||
1.0,
|
||||
2.0,
|
||||
3.0
|
||||
]
|
||||
},
|
||||
"_formatted": {
|
||||
"name_zh": "<em>进</em><em>击</em><em>的</em><em>巨人</em>",
|
||||
"author_zh": "諫山創",
|
||||
"description_zh": "<em>进</em><em>击</em><em>的</em><em>巨人</em>是日本的漫画系列,由諫山 創作画。",
|
||||
"id": "853",
|
||||
"_vectors": {
|
||||
"manual": [
|
||||
"1.0",
|
||||
"2.0",
|
||||
"3.0"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"query": "\"进击的巨人\"",
|
||||
"processingTimeMs": "[duration]",
|
||||
"limit": 20,
|
||||
"offset": 0,
|
||||
"estimatedTotalHits": 1
|
||||
}
|
||||
"###);
|
||||
snapshot!(code, @"200 OK");
|
||||
},
|
||||
)
|
||||
.await;
|
||||
|
||||
index
|
||||
.search(
|
||||
json!({"q": "\"进击的巨人\"", "attributesToHighlight": ["*"]}),
|
||||
|response, code| {
|
||||
snapshot!(response, @r###"
|
||||
{
|
||||
"hits": [
|
||||
{
|
||||
"name_zh": "进击的巨人",
|
||||
"author_zh": "諫山創",
|
||||
"description_zh": "进击的巨人是日本的漫画系列,由諫山 創作画。",
|
||||
"id": 853,
|
||||
"_vectors": {
|
||||
"manual": [
|
||||
1.0,
|
||||
2.0,
|
||||
3.0
|
||||
]
|
||||
},
|
||||
"_formatted": {
|
||||
"name_zh": "<em>进</em><em>击</em><em>的</em><em>巨人</em>",
|
||||
"author_zh": "諫山創",
|
||||
"description_zh": "<em>进</em><em>击</em><em>的</em><em>巨人</em>是日本的漫画系列,由諫山 創作画。",
|
||||
"id": "853",
|
||||
"_vectors": {
|
||||
"manual": [
|
||||
"1.0",
|
||||
"2.0",
|
||||
"3.0"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"query": "\"进击的巨人\"",
|
||||
"processingTimeMs": "[duration]",
|
||||
"limit": 20,
|
||||
"offset": 0,
|
||||
"estimatedTotalHits": 1
|
||||
}
|
||||
"###);
|
||||
snapshot!(code, @"200 OK");
|
||||
},
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn force_different_locales_with_pattern_nested() {
|
||||
let server = Server::new().await;
|
||||
|
|
|
@ -7,6 +7,7 @@ mod facet_search;
|
|||
mod formatted;
|
||||
mod geo;
|
||||
mod hybrid;
|
||||
#[cfg(not(feature = "chinese-pinyin"))]
|
||||
mod locales;
|
||||
mod matching_strategy;
|
||||
mod multi;
|
||||
|
@ -169,6 +170,7 @@ async fn negative_special_cases_search() {
|
|||
}
|
||||
|
||||
#[cfg(feature = "default")]
|
||||
#[cfg(not(feature = "chinese-pinyin"))]
|
||||
#[actix_rt::test]
|
||||
async fn test_kanji_language_detection() {
|
||||
let server = Server::new().await;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
source: meilisearch/tests/search/errors.rs
|
||||
---
|
||||
{
|
||||
"uid": 0,
|
||||
"uid": "[uid]",
|
||||
"indexUid": "tamo",
|
||||
"status": "succeeded",
|
||||
"type": "indexCreation",
|
||||
|
|
|
@ -9,6 +9,7 @@ static DEFAULT_SETTINGS_VALUES: Lazy<HashMap<&'static str, Value>> = Lazy::new(|
|
|||
let mut map = HashMap::new();
|
||||
map.insert("displayed_attributes", json!(["*"]));
|
||||
map.insert("searchable_attributes", json!(["*"]));
|
||||
map.insert("localized_attributes", json!(null));
|
||||
map.insert("filterable_attributes", json!([]));
|
||||
map.insert("distinct_attribute", json!(null));
|
||||
map.insert(
|
||||
|
@ -409,6 +410,7 @@ macro_rules! test_setting_routes {
|
|||
test_setting_routes!(
|
||||
filterable_attributes put,
|
||||
displayed_attributes put,
|
||||
localized_attributes put,
|
||||
searchable_attributes put,
|
||||
distinct_attribute put,
|
||||
stop_words put,
|
||||
|
|
BIN
meilisearch/tests/vector/intel_gen.txt.gz
Normal file
BIN
meilisearch/tests/vector/intel_gen.txt.gz
Normal file
Binary file not shown.
|
@ -1,3 +1,4 @@
|
|||
mod openai;
|
||||
mod rest;
|
||||
mod settings;
|
||||
|
||||
|
@ -10,6 +11,22 @@ use crate::common::index::Index;
|
|||
use crate::common::{default_settings, GetAllDocumentsOptions, Server};
|
||||
use crate::json;
|
||||
|
||||
async fn get_server_vector() -> Server {
|
||||
let server = Server::new().await;
|
||||
let (value, code) = server.set_features(json!({"vectorStore": true})).await;
|
||||
snapshot!(code, @"200 OK");
|
||||
snapshot!(value, @r###"
|
||||
{
|
||||
"vectorStore": true,
|
||||
"metrics": false,
|
||||
"logsRoute": false,
|
||||
"editDocumentsByFunction": false,
|
||||
"containsFilter": false
|
||||
}
|
||||
"###);
|
||||
server
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn add_remove_user_provided() {
|
||||
let server = Server::new().await;
|
||||
|
|
1873
meilisearch/tests/vector/openai.rs
Normal file
1873
meilisearch/tests/vector/openai.rs
Normal file
File diff suppressed because it is too large
Load diff
BIN
meilisearch/tests/vector/openai_responses.json.gz
Normal file
BIN
meilisearch/tests/vector/openai_responses.json.gz
Normal file
Binary file not shown.
BIN
meilisearch/tests/vector/openai_tokenized_responses.json.gz
Normal file
BIN
meilisearch/tests/vector/openai_tokenized_responses.json.gz
Normal file
Binary file not shown.
|
@ -5,9 +5,9 @@ use reqwest::IntoUrl;
|
|||
use wiremock::matchers::{method, path};
|
||||
use wiremock::{Mock, MockServer, Request, ResponseTemplate};
|
||||
|
||||
use crate::common::{Server, Value};
|
||||
use crate::common::Value;
|
||||
use crate::json;
|
||||
use crate::vector::GetAllDocumentsOptions;
|
||||
use crate::vector::{get_server_vector, GetAllDocumentsOptions};
|
||||
|
||||
async fn create_mock() -> (MockServer, Value) {
|
||||
let mock_server = MockServer::start().await;
|
||||
|
@ -265,22 +265,6 @@ async fn dummy_testing_the_mock() {
|
|||
snapshot!(body, @r###"{"data":[4,4,4]}"###);
|
||||
}
|
||||
|
||||
async fn get_server_vector() -> Server {
|
||||
let server = Server::new().await;
|
||||
let (value, code) = server.set_features(json!({"vectorStore": true})).await;
|
||||
snapshot!(code, @"200 OK");
|
||||
snapshot!(value, @r###"
|
||||
{
|
||||
"vectorStore": true,
|
||||
"metrics": false,
|
||||
"logsRoute": false,
|
||||
"editDocumentsByFunction": false,
|
||||
"containsFilter": false
|
||||
}
|
||||
"###);
|
||||
server
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn bad_request() {
|
||||
let (mock, _setting) = create_mock().await;
|
||||
|
@ -1816,7 +1800,7 @@ async fn server_custom_header() {
|
|||
}
|
||||
},
|
||||
"error": {
|
||||
"message": "Error while generating embeddings: runtime error: could not determine model dimensions:\n - test embedding failed with user error: could not authenticate against embedding server\n - server replied with `{\"error\":\"missing header 'my-nonstandard-auth'\"}`",
|
||||
"message": "Error while generating embeddings: runtime error: could not determine model dimensions:\n - test embedding failed with user error: could not authenticate against embedding server\n - server replied with `{\"error\":\"missing header 'my-nonstandard-auth'\"}`\n - Hint: Check the `apiKey` parameter in the embedder configuration",
|
||||
"code": "vector_embedding_error",
|
||||
"type": "invalid_request",
|
||||
"link": "https://docs.meilisearch.com/errors#vector_embedding_error"
|
||||
|
@ -1858,7 +1842,7 @@ async fn server_custom_header() {
|
|||
}
|
||||
},
|
||||
"error": {
|
||||
"message": "Error while generating embeddings: runtime error: could not determine model dimensions:\n - test embedding failed with user error: could not authenticate against embedding server\n - server replied with `{\"error\":\"thou shall not pass, Balrog\"}`",
|
||||
"message": "Error while generating embeddings: runtime error: could not determine model dimensions:\n - test embedding failed with user error: could not authenticate against embedding server\n - server replied with `{\"error\":\"thou shall not pass, Balrog\"}`\n - Hint: Check the `apiKey` parameter in the embedder configuration",
|
||||
"code": "vector_embedding_error",
|
||||
"type": "invalid_request",
|
||||
"link": "https://docs.meilisearch.com/errors#vector_embedding_error"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue