diff --git a/.code-samples.meilisearch.yaml b/.code-samples.meilisearch.yaml index 246c5a46fb..ffc2e439d0 100644 --- a/.code-samples.meilisearch.yaml +++ b/.code-samples.meilisearch.yaml @@ -544,6 +544,15 @@ update_localized_attribute_settings_1: |- --data-binary '[ {"locales": ["jpn"], "attributePatterns": ["*_ja"]} ]' +multilingual_dataset_guide_update_localized_attributes_1: |- + curl \ + -X PUT 'MEILISEARCH_URL/indexes/INDEX_NAME/settings/localized-attributes' \ + -H 'Content-Type: application/json' \ + --data-binary '[ + { "attributePatterns": ["*_en"], "locales": ["eng"] }, + { "attributePatterns": ["*_de"], "locales": ["deu"] }, + { "attributePatterns": ["*_fr"], "locales": ["fra"] } + ]' # delete_indexes_indexUid_settings_localized_attributes reset_localized_attribute_settings_1: |- curl \ @@ -1041,7 +1050,6 @@ phrase_search_1: |- -H 'Content-Type: application/json' \ --data-binary '{ "q": "\"african american\" horror" }' authorization_header_1: |- - # replace the MASTER_KEY placeholder with your master key curl \ -X GET 'MEILISEARCH_URL/keys' \ -H 'Authorization: Bearer MASTER_KEY' @@ -1138,9 +1146,6 @@ geosearch_guide_sort_usage_2: |- "rating:desc" ] }' -basic_security_tutorial_listing_1: |- - curl -X GET 'MEILISEARCH_URL/keys' \ - -H 'Authorization: Bearer MASTER_KEY' basic_security_tutorial_admin_1: |- curl \ -X POST 'MEILISEARCH_URL/indexes' \ @@ -1259,8 +1264,8 @@ search_parameter_guide_matching_strategy_3: |- }' date_guide_index_1: |- curl \ - -x POST 'MEILISEARCH_URL/indexes/games/documents' \ - -h 'content-type: application/json' \ + -X POST 'MEILISEARCH_URL/indexes/games/documents' \ + -H 'Content-Type: application/json' \ --data-binary @games.json date_guide_filterable_attributes_1: |- curl \ @@ -1510,7 +1515,7 @@ search_parameter_reference_locales_1: |- }' search_parameter_guide_hybrid_1: |- curl -X POST 'MEILISEARCH_URL/indexes/INDEX_NAME/search' \ - -H 'content-type: application/json' \ + -H 'Content-Type: application/json' \ --data-binary '{ "q": "kitchen utensils", "hybrid": { @@ -1520,7 +1525,7 @@ search_parameter_guide_hybrid_1: |- }' search_parameter_guide_vector_1: |- curl -X POST 'MEILISEARCH_URL/indexes/INDEX_NAME/search' \ - -H 'content-type: application/json' \ + -H 'Content-Type: application/json' \ --data-binary '{ "vector": [0, 1, 2], "hybrid": { @@ -1529,7 +1534,7 @@ search_parameter_guide_vector_1: |- }' search_parameter_reference_retrieve_vectors_1: |- curl -X POST 'MEILISEARCH_URL/indexes/INDEX_NAME/search' \ - -H 'content-type: application/json' \ + -H 'Content-Type: application/json' \ --data-binary '{ "q": "kitchen utensils", "retrieveVectors": true, @@ -1570,3 +1575,326 @@ list_index_fields_1: |- curl \ -X POST 'MEILISEARCH_URL/indexes/INDEX_NAME/fields' \ -H 'Content-Type: application/json' +update_experimental_features_chat_1: |- + curl \ + -X PATCH 'MEILISEARCH_URL/experimental-features/' \ + -H 'Content-Type: application/json' \ + --data-binary '{ + "chatCompletions": true + }' +update_experimental_features_contains_1: |- + curl \ + -X PATCH 'MEILISEARCH_URL/experimental-features/' \ + -H 'Content-Type: application/json' \ + --data-binary '{ + "containsFilter": true + }' +update_experimental_features_multimodal_1: |- + curl \ + -X PATCH 'MEILISEARCH_URL/experimental-features/' \ + -H 'Content-Type: application/json' \ + --data-binary '{ + "multimodal": true + }' +ai_search_user_embeddings_documents_1: |- + curl \ + -X POST 'MEILISEARCH_URL/indexes/INDEX_NAME/documents' \ + -H 'Content-Type: application/json' \ + --data-binary '[ + { "id": 0, "_vectors": { "EMBEDDER_NAME": [0, 0.8, -0.2]}, "text": "frying pan" }, + { "id": 1, "_vectors": { "EMBEDDER_NAME": [1, -0.2, 0]}, "text": "baking dish" } + ]' +ai_search_user_embeddings_search_vector_filter_1: |- + curl \ + -X POST 'MEILISEARCH_URL/indexes/INDEX_NAME/search' \ + -H 'Content-Type: application/json' \ + --data-binary '{ + "vector": [0, 1, 2], + "filter": "price < 10", + "sort": ["price:asc"], + "hybrid": { + "embedder": "EMBEDDER_NAME" + } + }' +user_provided_embeddings_settings_1: |- + curl \ + -X PATCH 'MEILISEARCH_URL/indexes/INDEX_NAME/settings' \ + -H 'Content-Type: application/json' \ + --data-binary '{ + "embedders": { + "EMBEDDER_NAME": { + "source": "userProvided", + "dimensions": MODEL_DIMENSIONS + } + } + }' +image_search_user_embeddings_search_1: |- + curl \ + -X POST 'MEILISEARCH_URL/indexes/INDEX_NAME/search' \ + -H 'Content-Type: application/json' \ + --data-binary '{ + "vector": VECTORIZED_QUERY, + "hybrid": { "embedder": "EMBEDDER_NAME" } + }' +image_search_user_embeddings_search_q_1: |- + curl \ + -X POST 'MEILISEARCH_URL/indexes/INDEX_NAME/search' \ + -H 'Content-Type: application/json' \ + --data-binary '{ + "vector": VECTORIZED_QUERY, + "hybrid": { "embedder": "EMBEDDER_NAME" }, + "q": "QUERY" + }' +federated_search_multi_search_1: |- + curl \ + -X POST 'MEILISEARCH_URL/multi-search' \ + -H 'Content-Type: application/json' \ + --data-binary '{ + "federation": {}, + "queries": [ + { + "indexUid": "chats", + "q": "natasha" + }, + { + "indexUid": "profiles", + "q": "natasha" + }, + { + "indexUid": "tickets", + "q": "natasha" + } + ] + }' +federated_search_multi_search_weight_1: |- + curl \ + -X POST 'MEILISEARCH_URL/multi-search' \ + -H 'Content-Type: application/json' \ + --data-binary '{ + "federation": {}, + "queries": [ + { + "indexUid": "chats", + "q": "rotondo" + }, + { + "indexUid": "profiles", + "q": "rotondo", + "federationOptions": { "weight": 1.2 } + }, + { + "indexUid": "tickets", + "q": "rotondo" + } + ] + }' +chat_create_key_1: |- + curl \ + -X POST 'MEILISEARCH_URL/keys' \ + -H 'Authorization: Bearer MEILISEARCH_KEY' \ + -H 'Content-Type: application/json' \ + --data-binary '{ + "name": "Chat API Key", + "description": "API key for chat completions", + "actions": ["search", "chatCompletions"], + "indexes": ["*"], + "expiresAt": null + }' +chat_index_settings_1: |- + curl \ + -X PATCH 'MEILISEARCH_URL/indexes/INDEX_NAME/settings' \ + -H 'Authorization: Bearer MEILISEARCH_KEY' \ + -H 'Content-Type: application/json' \ + --data-binary '{ + "chat": { + "description": "A comprehensive database of TYPE_OF_DOCUMENT containing titles, descriptions, genres, and release dates to help users searching for TYPE_OF_DOCUMENT", + "documentTemplate": "{% for field in fields %}{% if field.is_searchable and field.value != nil %}{{ field.name }}: {{ field.value }}\n{% endif %}{% endfor %}", + "documentTemplateMaxBytes": 400 + } + }' +chat_completions_1: |- + curl -N \ + -X POST 'MEILISEARCH_URL/chats/WORKSPACE_NAME/chat/completions' \ + -H 'Authorization: Bearer MEILISEARCH_API_KEY' \ + -H 'Content-Type: application/json' \ + --data-binary '{ + "model": "PROVIDER_MODEL_UID", + "messages": [ + { + "role": "user", + "content": "USER_PROMPT" + } + ], + "tools": [ + { + "type": "function", + "function": { + "name": "_meiliSearchProgress", + "description": "Reports real-time search progress to the user" + } + }, + { + "type": "function", + "function": { + "name": "_meiliSearchSources", + "description": "Provides sources and references for the information" + } + } + ] + }' +chat_get_settings_1: |- + curl \ + -X GET 'MEILISEARCH_URL/chats/WORKSPACE_NAME/settings' \ + -H "Authorization: Bearer MEILISEARCH_KEY" +chat_patch_settings_1: |- + curl \ + -X PATCH 'MEILISEARCH_URL/chats/WORKSPACE_NAME/settings' \ + -H "Authorization: Bearer MEILISEARCH_KEY" \ + -H "Content-Type: application/json" \ + --data-binary '{ "apiKey": "your-valid-api-key" }' +image_search_multimodal_settings_1: |- + curl \ + -X PATCH 'MEILISEARCH_URL/indexes/INDEX_NAME/settings' \ + -H 'Content-Type: application/json' \ + --data-binary '{ + "embedders": { + "MULTIMODAL_EMBEDDER_NAME": { + "source": "rest", + "url": "https://api.voyageai.com/v1/multimodal-embeddings", + "apiKey": "VOYAGE_API_KEY", + "indexingFragments": { + "TEXTUAL_FRAGMENT_NAME": { + "value": { + "content": [ + { + "type": "text", + "text": "A document named {{doc.title}} described as {{doc.description}}" + } + ] + } + }, + "IMAGE_FRAGMENT_NAME": { + "value": { + "content": [ + { + "type": "image_url", + "image_url": "{{doc.poster_url}}" + } + ] + } + } + }, + "searchFragments": { + "USER_TEXT_FRAGMENT": { + "value": { + "content": [ + { + "type": "text", + "text": "{{q}}" + } + ] + } + }, + "USER_SUBMITTED_IMAGE_FRAGMENT": { + "value": { + "content": [ + { + "type": "image_base64", + "image_base64": "data:{{media.image.mime}};base64,{{media.image.data}}" + } + ] + } + } + }, + "request": { + "inputs": ["{{fragment}}", "{{..}}"], + "model": "voyage-multimodal-3" + }, + "response": { + "data": [ + { "embedding": "{{embedding}}" }, + "{{..}}" + ] + } + } + } + }' +image_search_multimodal_search_text_1: |- + curl \ + -X POST 'MEILISEARCH_URL/indexes/INDEX_NAME/search' \ + -H 'Content-Type: application/json' \ + --data-binary '{ + "q": "a mountain sunset with snow", + "hybrid": { + "embedder": "MULTIMODAL_EMBEDDER_NAME" + } + }' +image_search_multimodal_search_image_1: |- + curl \ + -X POST 'MEILISEARCH_URL/indexes/INDEX_NAME/search' \ + -H 'Content-Type: application/json' \ + --data-binary '{ + "media": { + "image": { + "mime": "image/jpeg", + "data": "" + } + }, + "hybrid": { + "embedder": "MULTIMODAL_EMBEDDER_NAME" + } + }' +ai_search_getting_started_embedders_1: |- + curl \ + -X PATCH 'MEILISEARCH_URL/indexes/kitchenware/settings/embedders' \ + -H 'Content-Type: application/json' \ + --data-binary '{ + "products-openai": { + "source": "openAi", + "apiKey": "OPEN_AI_API_KEY", + "model": "text-embedding-3-small", + "documentTemplate": "An object used in a kitchen named '\''{{doc.name}}'\''" + } + }' +ai_search_getting_started_search_1: |- + curl \ + -X POST 'MEILISEARCH_URL/indexes/kitchenware/search' \ + -H 'Content-Type: application/json' \ + --data-binary '{ + "q": "kitchen utensils made of wood", + "hybrid": { + "embedder": "products-openai" + } + }' +personalization_search_1: |- + curl \ + -X POST 'MEILISEARCH_URL/indexes/INDEX_NAME/search' \ + -H 'Content-Type: application/json' \ + --data-binary '{ + "q": "wireless keyboard", + "personalize": { + "userContext": "The user prefers compact mechanical keyboards from Keychron or Logitech, with a mid-range budget and quiet keys for remote work." + } + }' +configure_rest_embedder_1: |- + curl \ + -X PATCH 'MEILISEARCH_URL/indexes/INDEX_NAME/settings/embedders' \ + -H 'Content-Type: application/json' \ + --data-binary '{ + "EMBEDDER_NAME": { + "source": "rest", + "url": "PROVIDER_URL", + "request": { + "model": "MODEL_NAME", + "input": ["{{text}}", "{{..}}"] + }, + "response": { + "data": [ + { "embedding": "{{embedding}}" }, + "{{..}}" + ] + }, + "apiKey": "PROVIDER_API_KEY", + "documentTemplate": "SHORT_AND_RELEVANT_DOCUMENT_TEMPLATE" + } + }' diff --git a/guides/relevancy/interpreting_ranking_scores.mdx b/guides/relevancy/interpreting_ranking_scores.mdx index 4dda81903d..09bba1131e 100644 --- a/guides/relevancy/interpreting_ranking_scores.mdx +++ b/guides/relevancy/interpreting_ranking_scores.mdx @@ -3,6 +3,8 @@ title: Interpreting ranking score details description: Learn how to understand ranking score details to see how Meilisearch evaluates each result and which rules determined their order. --- +import CodeSamplesSearchParameterGuideShowRankingScoreDetails1 from '/snippets/generated-code-samples/code_samples_search_parameter_guide_show_ranking_score_details_1.mdx'; + # How do I interpret ranking score details? [In the previous guide](/guides/relevancy/ordering_ranking_rules), we covered how ranking rules determine result order and how changing their sequence affects what your users see first. But when you're actually making those tweaks, how do you know if they're working the way you expect? @@ -15,19 +17,11 @@ You'll be able to see things like: did Proximity decide this result's position, When you search you can pass in an option to view the details of scoring and sorting using `“showRankingScoreDetails”: true` and it will return an indepth look at the ranking rules that you are working with -```markdown -curl \ - -X POST 'MEILISEARCH_URL/indexes/movies/search' \ - -H 'Content-Type: application/json' \ - --data-binary '{ - "q": "dragon", - "showRankingScoreDetails": true - }' -``` + Ranking Score details example -```markdown +```sh { "hits": [ { @@ -170,7 +164,7 @@ With this set up Meilisearch evaluates the text relevance rules first, *then* us "score": 0.3333333333333333 } } - + ``` ### What decided this? Reading the score details @@ -306,4 +300,4 @@ Moving Sort **one position** flipped the results. The ranking score details let - **Find where scores first diverge** — that's the rule that decided the final order - **Remember that Sort shows a `value`, not a `score`** It doesn't contribute to `_rankingScore`, which is why a higher-scored document can rank lower when Sort takes priority -Start with Sort after Group 1 rules (Scenario A) and adjust from there based on what your users expect. \ No newline at end of file +Start with Sort after Group 1 rules (Scenario A) and adjust from there based on what your users expect. diff --git a/learn/ai_powered_search/configure_rest_embedder.mdx b/learn/ai_powered_search/configure_rest_embedder.mdx index 8db9d9d29b..b283b797b1 100644 --- a/learn/ai_powered_search/configure_rest_embedder.mdx +++ b/learn/ai_powered_search/configure_rest_embedder.mdx @@ -3,6 +3,8 @@ title: Configure a REST embedder description: Create Meilisearch embedders using any provider with a REST API --- +import CodeSamplesConfigureRestEmbedder1 from '/snippets/generated-code-samples/code_samples_configure_rest_embedder_1.mdx'; + You can integrate any text embedding generator with Meilisearch if your chosen provider offers a public REST API. The process of integrating a REST embedder with Meilisearch varies depending on the provider and the way it structures its data. This guide shows you where to find the information you need, then walks you through configuring your Meilisearch embedder based on the information you found. @@ -326,31 +328,7 @@ You should also set a `documentTemplate`. Good templates are short and include o Now the embedder object is complete, update your index settings: -```sh -curl \ - -X PATCH 'MEILISEARCH_URL/indexes/INDEX_NAME/settings/embedders' \ - -H 'Content-Type: application/json' \ - --data-binary '{ - "EMBEDDER_NAME": { - "source": "rest", - "url": "PROVIDER_URL", - "request": { - "model": "MODEL_NAME", - "input": ["{{text}}", "{{..}}"], - }, - "response": { - "data": [ - { - "embedding": "{{embedding}}" - }, - "{{..}}" - ] - }, - "apiKey": "PROVIDER_API_KEY", - "documentTemplate": "SHORT_AND_RELEVANT_DOCUMENT_TEMPLATE" - } - }' -``` + ## Conclusion diff --git a/learn/ai_powered_search/getting_started_with_ai_search.mdx b/learn/ai_powered_search/getting_started_with_ai_search.mdx index cc12db088e..be4fea6cb0 100644 --- a/learn/ai_powered_search/getting_started_with_ai_search.mdx +++ b/learn/ai_powered_search/getting_started_with_ai_search.mdx @@ -4,6 +4,9 @@ sidebarTitle: Getting started with AI-powered search description: AI-powered search uses LLMs to retrieve search results. This tutorial shows you how to configure an OpenAI embedder and perform your first search. --- +import CodeSamplesAiSearchGettingStartedEmbedders1 from '/snippets/generated-code-samples/code_samples_ai_search_getting_started_embedders_1.mdx'; +import CodeSamplesAiSearchGettingStartedSearch1 from '/snippets/generated-code-samples/code_samples_ai_search_getting_started_search_1.mdx'; + [AI-powered search](https://meilisearch.com/solutions/vector-search), sometimes also called vector search or hybrid search, uses [large language models (LLMs)](https://en.wikipedia.org/wiki/Large_language_model) to retrieve search results based on the meaning and context of a query. This tutorial will walk you through configuring AI-powered search in your Meilisearch project. You will see how to set up an embedder with OpenAI, generate document embeddings, and perform your first search. @@ -116,19 +119,7 @@ This template starts by giving the general context of the document: `An object u Your embedder object is ready. Send it to Meilisearch by updating your index settings: -```sh -curl \ - -X PATCH 'MEILISEARCH_URL/indexes/kitchenware/settings/embedders' \ - -H 'Content-Type: application/json' \ - --data-binary '{ - "products-openai": { - "source": "openAi", - "apiKey": "OPEN_AI_API_KEY", - "model": "text-embedding-3-small", - "documentTemplate": "An object used in a kitchen named '{{doc.name}}'" - } - }' -``` + Replace `MEILISEARCH_URL` with the address of your Meilisearch project, and `OPEN_AI_API_KEY` with your [OpenAI API key](https://platform.openai.com/api-keys). @@ -138,17 +129,7 @@ Meilisearch and OpenAI will start processing your documents and updating your in AI-powered searches are very similar to basic text searches. You must query the `/search` endpoint with a request containing both the `q` and the `hybrid` parameters: -```sh -curl \ - -X POST 'MEILISEARCH_URL/indexes/kitchenware/search' \ - -H 'content-type: application/json' \ - --data-binary '{ - "q": "kitchen utensils made of wood", - "hybrid": { - "embedder": "products-openai" - } - }' -``` + For this tutorial, `hybrid` is an object with a single `embedder` field. diff --git a/learn/ai_powered_search/image_search_with_multimodal_embeddings.mdx b/learn/ai_powered_search/image_search_with_multimodal_embeddings.mdx index ef9fcef270..32f459059f 100644 --- a/learn/ai_powered_search/image_search_with_multimodal_embeddings.mdx +++ b/learn/ai_powered_search/image_search_with_multimodal_embeddings.mdx @@ -3,6 +3,11 @@ title: Image search with multimodal embeddings description: This article shows you the main steps for performing multimodal text-to-image searches --- +import CodeSamplesUpdateExperimentalFeaturesMultimodal1 from '/snippets/generated-code-samples/code_samples_update_experimental_features_multimodal_1.mdx'; +import CodeSamplesImageSearchMultimodalSettings1 from '/snippets/generated-code-samples/code_samples_image_search_multimodal_settings_1.mdx'; +import CodeSamplesImageSearchMultimodalSearchText1 from '/snippets/generated-code-samples/code_samples_image_search_multimodal_search_text_1.mdx'; +import CodeSamplesImageSearchMultimodalSearchImage1 from '/snippets/generated-code-samples/code_samples_image_search_multimodal_search_image_1.mdx'; + This guide shows the main steps to search through a database of images using Meilisearch's experimental multimodal embeddings. ## Requirements @@ -15,14 +20,7 @@ This guide shows the main steps to search through a database of images using Mei First, enable the `multimodal` experimental feature: -```sh -curl \ - -X PATCH 'MEILISEARCH_URL/experimental-features/' \ - -H 'Content-Type: application/json' \ - --data-binary '{ - "multimodal": true - }' -``` + You may also enable multimodal in your Meilisearch Cloud project's general settings, under "Experimental features". @@ -111,79 +109,7 @@ Each semantic search query for this embedder should match exactly one search fra Your embedder should look similar to this example with all fragments and embedding provider data: -```sh -curl \ - -X PATCH 'MEILISEARCH_URL/indexes/INDEX_NAME/settings' \ - -H 'Content-Type: application/json' \ - --data-binary '{ - "embedders": { - "MULTIMODAL_EMBEDDER_NAME": { - "source": "rest", - "url": "https://api.voyageai.com/v1/multimodal-embeddings", - "apiKey": "VOYAGE_API_KEY", - "indexingFragments": { - "TEXTUAL_FRAGMENT_NAME": { - "value": { - "content": [ - { - "type": "text", - "text": "A document named {{doc.title}} described as {{doc.description}}" - } - ] - } - }, - "IMAGE_FRAGMENT_NAME": { - "value": { - "content": [ - { - "type": "image_url", - "image_url": "{{doc.poster_url}}" - } - ] - } - } - }, - "searchFragments": { - "USER_TEXT_FRAGMENT": { - "value": { - "content": [ - { - "type": "text", - "text": "{{q}}" - } - ] - } - }, - "USER_SUBMITTED_IMAGE_FRAGMENT": { - "value": { - "content": [ - { - "type": "image_base64", - "image_base64": "data:{{media.image.mime}};base64,{{media.image.data}}" - } - ] - } - } - }, - "request": { - "inputs": [ - "{{fragment}}", - "{{..}}" - ], - "model": "voyage-multimodal-3" - }, - "response": { - "data": [ - { - "embedding": "{{embedding}}" - }, - "{{..}}" - ] - } - } - } - }' -``` + Since the `source` of this embedder is `rest`, you must also specify a `request` and a `response` fields. These respectively instruct Meilisearch on how to structure the request sent to the embeddings provider, and where to find the embeddings in the provider's response. @@ -201,36 +127,13 @@ The final step is to perform searches using different types of content. Use the following search query to retrieve a mix of documents with images matching the description, documents with and documents containing the specified keywords: -```sh -curl -X POST 'http://localhost:7700/indexes/INDEX_NAME/search' \ - -H 'Content-Type: application/json' \ - --data-binary '{ - "q": "a mountain sunset with snow", - "hybrid": { - "embedder": "MULTIMODAL_EMBEDDER_NAME" - } - }' -``` + ### Use an image to search for images You can also use an image to search for other, similar images: -```sh -curl -X POST 'http://localhost:7700/indexes/INDEX_NAME/search' \ - -H 'Content-Type: application/json' \ - --data-binary '{ - "media": { - "image": { - "mime": "image/jpeg", - "data": "" - } - }, - "hybrid": { - "embedder": "MULTIMODAL_EMBEDDER_NAME" - } - }' -``` + In most cases you will need a GUI interface that allows users to submit their images and converts these images to Base64 format. Creating this is outside the scope of this guide. diff --git a/learn/ai_powered_search/image_search_with_user_provided_embeddings.mdx b/learn/ai_powered_search/image_search_with_user_provided_embeddings.mdx index c7f78de472..9c2242a32c 100644 --- a/learn/ai_powered_search/image_search_with_user_provided_embeddings.mdx +++ b/learn/ai_powered_search/image_search_with_user_provided_embeddings.mdx @@ -3,6 +3,10 @@ title: Image search with user-provided embeddings description: This article shows you the main steps for performing multimodal text-to-image searches --- +import CodeSamplesUserProvidedEmbeddingsSettings1 from '/snippets/generated-code-samples/code_samples_user_provided_embeddings_settings_1.mdx'; +import CodeSamplesImageSearchUserEmbeddingsSearch1 from '/snippets/generated-code-samples/code_samples_image_search_user_embeddings_search_1.mdx'; +import CodeSamplesImageSearchUserEmbeddingsSearchQ1 from '/snippets/generated-code-samples/code_samples_image_search_user_embeddings_search_q_1.mdx'; + This article shows you the main steps for performing multimodal searches where you can use text to search through a database of images with no associated metadata. ## Requirements @@ -28,19 +32,7 @@ In most cases your system should run these steps periodically or whenever you up Configure the `embedder` index setting, settings its source to `userProvided`: -```sh -curl \ - -X PATCH 'MEILISEARCH_URL/indexes/movies/settings' \ - -H 'Content-Type: application/json' \ - --data-binary '{ - "embedders": { - "EMBEDDER_NAME": { - "source": "userProvided", - "dimensions": MODEL_DIMENSIONS - } - } - }' -``` + Replace `EMBEDDER_NAME` with the name you wish to give your embedder. Replace `MODEL_DIMENSIONS` with the number of dimensions of your chosen model. @@ -62,32 +54,13 @@ Since you are using a `userProvided` embedder, you must also generate the embedd Once you have the query's vector, pass it to the `vector` search parameter to perform a semantic AI-powered search: -```sh -curl -X POST -H 'content-type: application/json' \ - 'localhost:7700/indexes/products/search' \ - --data-binary '{ - "vector": VECTORIZED_QUERY, - "hybrid": { - "embedder": "EMBEDDER_NAME", - } - }' -``` + Replace `VECTORIZED_QUERY` with the embedding generated by your provider and `EMBEDDER_NAME` with your embedder. If your images have any associated metadata, you may perform a hybrid search by including the original `q`: -```sh -curl -X POST -H 'content-type: application/json' \ - 'localhost:7700/indexes/products/search' \ - --data-binary '{ - "vector": VECTORIZED_QUERY, - "hybrid": { - "embedder": "EMBEDDER_NAME", - } - "q": "QUERY", - }' -``` + ## Conclusion diff --git a/learn/ai_powered_search/search_with_user_provided_embeddings.mdx b/learn/ai_powered_search/search_with_user_provided_embeddings.mdx index 1dba009d30..9c8362323b 100644 --- a/learn/ai_powered_search/search_with_user_provided_embeddings.mdx +++ b/learn/ai_powered_search/search_with_user_provided_embeddings.mdx @@ -4,6 +4,11 @@ sidebarTitle: Use AI-powered search with user-provided embeddings description: This guide shows how to perform AI-powered searches with user-generated embeddings instead of relying on a third-party tool. --- +import CodeSamplesUserProvidedEmbeddingsSettings1 from '/snippets/generated-code-samples/code_samples_user_provided_embeddings_settings_1.mdx'; +import CodeSamplesAiSearchUserEmbeddingsDocuments1 from '/snippets/generated-code-samples/code_samples_ai_search_user_embeddings_documents_1.mdx'; +import CodeSamplesSearchParameterGuideVector1 from '/snippets/generated-code-samples/code_samples_search_parameter_guide_vector_1.mdx'; +import CodeSamplesAiSearchUserEmbeddingsSearchVectorFilter1 from '/snippets/generated-code-samples/code_samples_ai_search_user_embeddings_search_vector_filter_1.mdx'; + This guide shows how to perform AI-powered searches with user-generated embeddings instead of relying on a third-party tool. ## Requirements @@ -14,36 +19,17 @@ This guide shows how to perform AI-powered searches with user-generated embeddin Configure the `embedder` index setting, settings its source to `userProvided`: -```sh -curl \ - -X PATCH 'MEILISEARCH_URL/indexes/movies/settings' \ - -H 'Content-Type: application/json' \ - --data-binary '{ - "embedders": { - "image2text": { - "source": "userProvided", - "dimensions": 3 - } - } - }' -``` + -Embedders with `source: userProvided` are incompatible with `documentTemplate` and `documentTemplateMaxBytes`. +Embedders with `source: userProvided` are incompatible with `documentTemplate` and `documentTemplateMaxBytes`. ## Add documents to Meilisearch Next, use [the `/documents` endpoint](/reference/api/documents/list-documents-with-get?utm_campaign=vector-search&utm_source=docs&utm_medium=vector-search-guide) to upload vectorized documents. Place vector data in your documents' `_vectors` field: -```sh -curl -X POST -H 'content-type: application/json' \ -'localhost:7700/indexes/products/documents' \ ---data-binary '[ - { "id": 0, "_vectors": {"image2text": [0, 0.8, -0.2]}, "text": "frying pan" }, - { "id": 1, "_vectors": {"image2text": [1, -0.2, 0]}, "text": "baking dish" } -]' -``` + ## Vector search with user-provided embeddings @@ -51,30 +37,10 @@ When using a custom embedder, you must vectorize both your documents and user qu Once you have the query's vector, pass it to the `vector` search parameter to perform an AI-powered search: -```sh -curl -X POST -H 'content-type: application/json' \ - 'localhost:7700/indexes/products/search' \ - --data-binary '{ - "vector": [0, 1, 2], - "hybrid": { - "embedder": "image2text" - } - }' -``` + `vector` must be an array of numbers indicating the search vector. You must generate these yourself when using vector search with user-provided embeddings. `vector` can be used together with [other search parameters](/reference/api/search/search-with-post?utm_campaign=vector-search&utm_source=docs&utm_medium=vector-search-guide), including [`filter`](/reference/api/search/search-with-post#body-filter) and [`sort`](/reference/api/search/search-with-post#body-sort): -```sh -curl -X POST -H 'content-type: application/json' \ - 'localhost:7700/indexes/products/search' \ - --data-binary '{ - "vector": [0, 1, 2], - "filter": "price < 10", - "sort": ["price:asc"], - "hybrid": { - "embedder": "image2text" - } - }' -``` + diff --git a/learn/async/task_webhook.mdx b/learn/async/task_webhook.mdx index 5516e7c043..068d32dc79 100644 --- a/learn/async/task_webhook.mdx +++ b/learn/async/task_webhook.mdx @@ -5,6 +5,8 @@ description: Learn how to use webhooks to react to changes in your Meilisearch d sidebarDepth: 3 --- +import CodeSamplesAddOrReplaceDocuments1 from '/snippets/generated-code-samples/code_samples_add_or_replace_documents_1.mdx'; + This guide teaches you how to configure a single webhook via instance options to notify a URL when Meilisearch completes a [task](/learn/async/asynchronous_operations). @@ -32,36 +34,27 @@ You may also define the webhook URL with environment variables or in the configu Depending on your setup, you may need to provide an authorization header. Provide it to `task-webhook-authorization-header`: ```sh -meilisearch --task-webhook-url http://localhost:8000 --task-webhook-authorization-header Bearer aSampleMasterKey +meilisearch \ + --task-webhook-url http://localhost:8000 \ + --task-webhook-authorization-header Bearer aSampleMasterKey ``` ## Test the webhook -A common asynchronous operation is adding or updating documents to an index. The following example adds a test document to our `books` index: +A common asynchronous operation is adding or updating documents to an index. The following example adds a test document to our `movies` index: -```sh -curl \ - -X POST 'MEILISEARCH_URL/indexes/books/documents' \ - -H 'Content-Type: application/json' \ - --data-binary '[ - { - "id": 1, - "title": "Nuestra parte de noche", - "author": "Mariana Enríquez" - } - ]' -``` + When Meilisearch finishes indexing this document, it will send a `POST` request the URL you configured with `--task-webhook-url`. The request body will be one or more task objects in [ndjson](https://github.com/ndjson/ndjson-spec) format: ```ndjson -{"uid":4,"indexUid":"books","status":"succeeded","type":"documentAdditionOrUpdate","canceledBy":null,"details.receivedDocuments":1,"details.indexedDocuments":1,"duration":"PT0.001192S","enqueuedAt":"2022-08-04T12:28:15.159167Z","startedAt":"2022-08-04T12:28:15.161996Z","finishedAt":"2022-08-04T12:28:15.163188Z"} +{"uid":4,"indexUid":"movies","status":"succeeded","type":"documentAdditionOrUpdate","canceledBy":null,"details.receivedDocuments":1,"details.indexedDocuments":1,"duration":"PT0.001192S","enqueuedAt":"2022-08-04T12:28:15.159167Z","startedAt":"2022-08-04T12:28:15.161996Z","finishedAt":"2022-08-04T12:28:15.163188Z"} ``` If Meilisearch has batched multiple tasks, it will only trigger the webhook once all tasks in a batch are finished. In this case, the response payload will include all tasks, each separated by a new line: ```ndjson -{"uid":4,"indexUid":"books","status":"succeeded","type":"documentAdditionOrUpdate","canceledBy":null,"details.receivedDocuments":1,"details.indexedDocuments":1,"duration":"PT0.001192S","enqueuedAt":"2022-08-04T12:28:15.159167Z","startedAt":"2022-08-04T12:28:15.161996Z","finishedAt":"2022-08-04T12:28:15.163188Z"} -{"uid":5,"indexUid":"books","status":"succeeded","type":"documentAdditionOrUpdate","canceledBy":null,"details.receivedDocuments":1,"details.indexedDocuments":1,"duration":"PT0.001192S","enqueuedAt":"2022-08-04T12:28:15.159167Z","startedAt":"2022-08-04T12:28:15.161996Z","finishedAt":"2022-08-04T12:28:15.163188Z"} -{"uid":6,"indexUid":"books","status":"succeeded","type":"documentAdditionOrUpdate","canceledBy":null,"details.receivedDocuments":1,"details.indexedDocuments":1,"duration":"PT0.001192S","enqueuedAt":"2022-08-04T12:28:15.159167Z","startedAt":"2022-08-04T12:28:15.161996Z","finishedAt":"2022-08-04T12:28:15.163188Z"} +{"uid":4,"indexUid":"movies","status":"succeeded","type":"documentAdditionOrUpdate","canceledBy":null,"details.receivedDocuments":1,"details.indexedDocuments":1,"duration":"PT0.001192S","enqueuedAt":"2022-08-04T12:28:15.159167Z","startedAt":"2022-08-04T12:28:15.161996Z","finishedAt":"2022-08-04T12:28:15.163188Z"} +{"uid":5,"indexUid":"movies","status":"succeeded","type":"documentAdditionOrUpdate","canceledBy":null,"details.receivedDocuments":1,"details.indexedDocuments":1,"duration":"PT0.001192S","enqueuedAt":"2022-08-04T12:28:15.159167Z","startedAt":"2022-08-04T12:28:15.161996Z","finishedAt":"2022-08-04T12:28:15.163188Z"} +{"uid":6,"indexUid":"movies","status":"succeeded","type":"documentAdditionOrUpdate","canceledBy":null,"details.receivedDocuments":1,"details.indexedDocuments":1,"duration":"PT0.001192S","enqueuedAt":"2022-08-04T12:28:15.159167Z","startedAt":"2022-08-04T12:28:15.161996Z","finishedAt":"2022-08-04T12:28:15.163188Z"} ``` diff --git a/learn/chat/chat_tooling_reference.md b/learn/chat/chat_tooling_reference.mdx similarity index 97% rename from learn/chat/chat_tooling_reference.md rename to learn/chat/chat_tooling_reference.mdx index 5485abb475..c928089434 100644 --- a/learn/chat/chat_tooling_reference.md +++ b/learn/chat/chat_tooling_reference.mdx @@ -3,19 +3,14 @@ title: Chat tooling reference description: An exhaustive reference of special chat tools supported by Meilisearch --- +import CodeSamplesUpdateExperimentalFeaturesChat1 from '/snippets/generated-code-samples/code_samples_update_experimental_features_chat_1.mdx'; + When creating your conversational search agent, you may be able to extend the model's capabilities with a number of tools. This page lists Meilisearch-specific tools that may improve user experience. This is an experimental feature. Use the Meilisearch Cloud UI or the experimental features endpoint to activate it: -```sh -curl \ - -X PATCH 'MEILISEARCH_URL/experimental-features/' \ - -H 'Content-Type: application/json' \ - --data-binary '{ - "chatCompletions": true - }' -``` + ## Meilisearch chat tools diff --git a/learn/chat/getting_started_with_chat.mdx b/learn/chat/getting_started_with_chat.mdx index ee180d9edf..3a3bc54e04 100644 --- a/learn/chat/getting_started_with_chat.mdx +++ b/learn/chat/getting_started_with_chat.mdx @@ -3,6 +3,14 @@ title: Getting started with conversational search description: This article walks you through implementing Meilisearch's chat completions feature to create conversational search experiences in your application. --- +import CodeSamplesUpdateExperimentalFeaturesChat1 from '/snippets/generated-code-samples/code_samples_update_experimental_features_chat_1.mdx'; +import CodeSamplesAuthorizationHeader1 from '/snippets/generated-code-samples/code_samples_authorization_header_1.mdx'; +import CodeSamplesChatCreateKey1 from '/snippets/generated-code-samples/code_samples_chat_create_key_1.mdx'; +import CodeSamplesChatIndexSettings1 from '/snippets/generated-code-samples/code_samples_chat_index_settings_1.mdx'; +import CodeSamplesChatCompletions1 from '/snippets/generated-code-samples/code_samples_chat_completions_1.mdx'; +import CodeSamplesChatGetSettings1 from '/snippets/generated-code-samples/code_samples_chat_get_settings_1.mdx'; +import CodeSamplesChatPatchSettings1 from '/snippets/generated-code-samples/code_samples_chat_patch_settings_1.mdx'; + To successfully implement a conversational search interface you must follow three steps: configure indexes for chat usage, create a chat workspaces, and build a chat interface. ## Prerequisites @@ -19,15 +27,7 @@ Before starting, ensure you have: First, enable the chat completions experimental feature: -```bash -curl \ - -X PATCH 'MEILISEARCH_URL/experimental-features/' \ - -H 'Authorization: Bearer MEILISEARCH_KEY' \ - -H 'Content-Type: application/json' \ - --data-binary '{ - "chatCompletions": true - }' -``` + Conversational search is still in early development. Conversational agents may occasionally hallucinate inaccurate and misleading information, so it is important to closely monitor it in production environments. @@ -37,10 +37,7 @@ Conversational search is still in early development. Conversational agents may o When Meilisearch runs with a master key on an instance created after v1.15.1, it automatically generates a "Default Chat API Key" with `chatCompletions` and `search` permissions on all indexes. Check if you have the key using: -```bash -curl MEILISEARCH_URL/keys \ - -H "Authorization: Bearer MEILISEARCH_KEY" -``` + Look for the key with the description "Default Chat API Key". @@ -48,37 +45,13 @@ Look for the key with the description "Default Chat API Key". If your instance does not have a Default Chat API Key, create one manually: -```bash -curl \ - -X POST 'MEILISEARCH_URL/keys' \ - -H 'Authorization: Bearer MEILISEARCH_KEY' \ - -H 'Content-Type: application/json' \ - --data-binary '{ - "name": "Chat API Key", - "description": "API key for chat completions", - "actions": ["search", "chatCompletions"], - "indexes": ["*"], - "expiresAt": null - }' -``` + ## Configure your indexes After activating the `/chats` route and obtaining an API key with chat permissions, configure the `chat` settings for each index you want to be searchable via chat UI: -```bash -curl \ - -X PATCH 'MEILISEARCH_URL/indexes/INDEX_NAME/settings' \ - -H 'Authorization: Bearer MEILISEARCH_KEY' \ - -H 'Content-Type: application/json' \ - --data-binary '{ - "chat": { - "description": "A comprehensive database of TYPE_OF_DOCUMENT containing titles, descriptions, genres, and release dates to help users searching for TYPE_OF_DOCUMENT", - "documentTemplate": "{% for field in fields %}{% if field.is_searchable and field.value != nil %}{{ field.name }}: {{ field.value }}\n{% endif %}{% endfor %}", - "documentTemplateMaxBytes": 400 - } - }' -``` + - `description` gives the initial context of the conversation to the LLM. A good description improves relevance of the chat's answers - `documentTemplate` defines the document data Meilisearch sends to the AI provider. This template outputs all searchable fields in your documents, which may not be ideal if your documents have many fields. Consult the best [document template best practices](/learn/ai_powered_search/document_template_best_practices) article for more guidance @@ -168,37 +141,7 @@ Which fields are mandatory will depend on your chosen provider `source`. In most You have finished configuring your conversational search agent. To test everything is working as expected, send a streaming `curl` query to the chat completions API route: -```bash -curl -N \ - -X POST 'MEILISEARCH_URL/chats/WORKSPACE_NAME/chat/completions' \ - -H 'Authorization: Bearer MEILISEARCH_API_KEY' \ - -H 'Content-Type: application/json' \ - --data-binary '{ - "model": "PROVIDER_MODEL_UID", - "messages": [ - { - "role": "user", - "content": "USER_PROMPT" - } - ], - "tools": [ - { - "type": "function", - "function": { - "name": "_meiliSearchProgress", - "description": "Reports real-time search progress to the user" - } - }, - { - "type": "function", - "function": { - "name": "_meiliSearchSources", - "description": "Provides sources and references for the information" - } - } - ] - }' -``` + - `model` is mandatory and must indicate a model supported by your chosen `source` - `messages` contains the messages exchanged between the conversational search agent and the user @@ -226,7 +169,7 @@ Meilisearch's chat endpoint was designed to be OpenAI-compatible. This means you Integrating Meilisearch and the OpenAI SDK with JavaScript would look like this: -```javascript JavaScript +```javascript import OpenAI from 'openai'; const client = new OpenAI({ @@ -272,7 +215,7 @@ Take particular note of the last lines, which output the streamed responses to t - Use either the master key or the "Default Chat API Key" - Don't use search or admin API keys for chat endpoints -- Find your chat key: `curl MEILISEARCH_URL/keys -H "Authorization: Bearer MEILISEARCH_KEY"` +- Find your chat key with the [list keys endpoint](/reference/api/keys/get-api-keys) #### "Socket connection closed unexpectedly" @@ -282,19 +225,11 @@ Take particular note of the last lines, which output the streamed responses to t 1. Check workspace configuration: - ```bash - curl MEILISEARCH_URL/chats/WORKSPACE_NAME/settings \ - -H "Authorization: Bearer MEILISEARCH_KEY" - ``` + 2. Update with valid API key: - ```bash - curl -X PATCH MEILISEARCH_URL/chats/WORKSPACE_NAME/settings \ - -H "Authorization: Bearer MEILISEARCH_KEY" \ - -H "Content-Type: application/json" \ - -d '{"apiKey": "your-valid-api-key"}' - ``` + #### Chat not searching the database diff --git a/learn/engine/datatypes.mdx b/learn/engine/datatypes.mdx index 1d24fd52d1..1f534dbea4 100644 --- a/learn/engine/datatypes.mdx +++ b/learn/engine/datatypes.mdx @@ -260,7 +260,7 @@ curl \ -H 'Content-Type: application/json' \ --data-binary '{ "q": "", - "filter": "(appointments.date = 2022-01-01 AND appointments.doctor = 'Jester Lavorre')" + "filter": "(appointments.date = 2022-01-01 AND appointments.doctor = '\''Jester Lavorre'\'')" }' ``` diff --git a/learn/filtering_and_sorting/filter_expression_reference.mdx b/learn/filtering_and_sorting/filter_expression_reference.mdx index 5f58318843..a03528be04 100644 --- a/learn/filtering_and_sorting/filter_expression_reference.mdx +++ b/learn/filtering_and_sorting/filter_expression_reference.mdx @@ -5,6 +5,7 @@ description: The `filter` search parameter expects a filter expression. Filter e --- import { NoticeTag } from '/snippets/notice_tag.mdx'; +import CodeSamplesUpdateExperimentalFeaturesContains1 from '/snippets/generated-code-samples/code_samples_update_experimental_features_contains_1.mdx'; The `filter` search parameter expects a filter expression. Filter expressions are made of attributes, values, and several operators. @@ -198,14 +199,7 @@ NOT dairy_product.name CONTAINS kef This is an experimental feature. Use the experimental features endpoint to activate it: -```sh -curl \ - -X PATCH 'MEILISEARCH_URL/experimental-features/' \ - -H 'Content-Type: application/json' \ - --data-binary '{ - "containsFilter": true - }' -``` + ### `STARTS WITH` diff --git a/learn/indexing/multilingual-datasets.mdx b/learn/indexing/multilingual-datasets.mdx index 4c4708489c..9cf414bfa6 100644 --- a/learn/indexing/multilingual-datasets.mdx +++ b/learn/indexing/multilingual-datasets.mdx @@ -3,6 +3,8 @@ title: Handling multilingual datasets description: This guide covers indexing strategies, language-specific tokenizers, and best practices for aligning document and query tokenization. --- +import CodeSamplesMultilingualDatasetGuideUpdateLocalizedAttributes1 from '/snippets/generated-code-samples/code_samples_multilingual_dataset_guide_update_localized_attributes_1.mdx'; + When working with datasets that include content in multiple languages, it’s important to ensure that both documents and queries are processed correctly. This guide explains how to index and search multilingual datasets in Meilisearch, highlighting best practices, useful features, and what to avoid. ## Recommended indexing strategy @@ -76,10 +78,10 @@ For search to work effectively, **queries must be tokenized and normalized in th ### Aligning document and query tokenization -To keep queries and documents consistent, Meilisearch provides configuration options for both sides. Meilisearch uses the same `locales` configuration concept for both documents and queries: +To keep queries and documents consistent, Meilisearch provides configuration options for both sides. Meilisearch uses the same `locales` configuration concept for both documents and queries: -- In **documents**, `locales` are declared through `localizedAttributes`. -- In **queries**, `locales` are passed as a [search parameter]. +- In **documents**, `locales` are declared through `localizedAttributes`. +- In **queries**, `locales` are passed as a [search parameter]. #### Declaring locales for documents @@ -96,13 +98,7 @@ For example, if your dataset contains multilingual titles, you can declare which } ``` -```javascript -client.index('INDEX_NAME').updateLocalizedAttributes([ - { attributePatterns: ['*_en'], locales: ['eng'] }, - { attributePatterns: ['*_de'], locales: ['deu'] }, - { attributePatterns: ['*_fr'], locales: ['fra'] } -]) -``` + #### Specifying locales for queries @@ -116,5 +112,5 @@ This ensures queries are interpreted with the correct tokenizer and normalizatio ## Conclusion -Handling multilingual datasets in Meilisearch requires careful planning of both indexing and querying. -By choosing the right indexing strategy, and explicitly configuring languages with `localizedAttributes` and `locales`, you ensure that documents and queries are processed consistently. +Handling multilingual datasets in Meilisearch requires careful planning of both indexing and querying. +By choosing the right indexing strategy, and explicitly configuring languages with `localizedAttributes` and `locales`, you ensure that documents and queries are processed consistently. diff --git a/learn/indexing/optimize_indexing_performance.mdx b/learn/indexing/optimize_indexing_performance.mdx index 521315ef9f..9a911a5c16 100644 --- a/learn/indexing/optimize_indexing_performance.mdx +++ b/learn/indexing/optimize_indexing_performance.mdx @@ -3,6 +3,8 @@ title: Optimize indexing performance with batch statistics description: Learn how to analyze the `progressTrace` to identify and resolve indexing bottlenecks in Meilisearch. --- +import CodeSamplesUpdateFacetSearchSettings1 from '/snippets/generated-code-samples/code_samples_update_facet_search_settings_1.mdx'; + # Optimize indexing performance by analyzing batch statistics Indexing performance can vary significantly depending on your dataset, index settings, and hardware. The [batch object](/reference/api/async-task-management/list-batches) provides information about the progress of asynchronous indexing operations. @@ -105,12 +107,7 @@ If you see: [Facet searching](/learn/filtering_and_sorting/search_with_facet_filters#searching-facet-values) is raking significant indexing time. If your application doesn’t use facets, disable the feature: -```bash -curl \ - -X PUT 'MEILISEARCH_URL/indexes/INDEX_UID/settings/facet-search' \ - -H 'Content-Type: application/json' \ - --data-binary 'false' -``` + ## Learn more diff --git a/learn/multi_search/performing_federated_search.mdx b/learn/multi_search/performing_federated_search.mdx index c73aa35797..eb1d20ea1a 100644 --- a/learn/multi_search/performing_federated_search.mdx +++ b/learn/multi_search/performing_federated_search.mdx @@ -4,6 +4,9 @@ sidebarTitle: Using multi-search to perform a federated search description: In this tutorial you will see how to perform a query searching multiple indexes at the same time to obtain a single list of results. --- +import CodeSamplesFederatedSearchMultiSearch1 from '/snippets/generated-code-samples/code_samples_federated_search_multi_search_1.mdx'; +import CodeSamplesFederatedSearchMultiSearchWeight1 from '/snippets/generated-code-samples/code_samples_federated_search_multi_search_weight_1.mdx'; + Meilisearch allows you to make multiple search requests at the same time with the `/multi-search` endpoint. A federated search is a multi-search that returns results from multiple queries in a single list. In this tutorial you will see how to create separate indexes containing different types of data from a CRM application. You will then perform a query searching all these indexes at the same time to obtain a single list of results. @@ -20,9 +23,9 @@ Download the following datasets: `crm- Add the datasets to Meilisearch and create three separate indexes, `profiles`, `chats`, and `tickets`: ```sh -curl -X POST 'MEILISEARCH_URL/indexes/profiles' -H 'Content-Type: application/json' --data-binary @crm-profiles.json && -curl -X POST 'MEILISEARCH_URL/indexes/chats' -H 'Content-Type: application/json' --data-binary @crm-chats.json && -curl -X POST 'MEILISEARCH_URL/indexes/tickets' -H 'Content-Type: application/json' --data-binary @crm-tickets.json +curl -X POST 'MEILISEARCH_URL/indexes/profiles' -H 'Content-Type: application/json' --data-binary @crm-profiles.json && +curl -X POST 'MEILISEARCH_URL/indexes/chats' -H 'Content-Type: application/json' --data-binary @crm-chats.json && +curl -X POST 'MEILISEARCH_URL/indexes/tickets' -H 'Content-Type: application/json' --data-binary @crm-tickets.json ``` [Use the tasks endpoint](/learn/async/working_with_tasks) to check the indexing status. Once Meilisearch successfully indexed all three datasets, you are ready to perform a federated search. @@ -33,28 +36,7 @@ When you are looking for Natasha Nguyen's email address in your CRM application, Use the `/multi-search` endpoint with the `federation` parameter to query the three indexes simultaneously: -```sh -curl \ - -X POST 'MEILISEARCH_URL/multi-search' \ - -H 'Content-Type: application/json' \ - --data-binary '{ - "federation": {}, - "queries": [ - { - "indexUid": "chats", - "q": "natasha" - }, - { - "indexUid": "profiles", - "q": "natasha" - }, - { - "indexUid": "tickets", - "q": "natasha" - } - ] - }' -``` + Meilisearch should respond with a single list of search results: @@ -87,31 +69,7 @@ Since this is a CRM application, users have profiles with their preferred contac Use the `weight` property of the `federation` parameter to boost results coming from a specific query: -```sh -curl \ - -X POST 'MEILISEARCH_URL/multi-search' \ - -H 'Content-Type: application/json' \ - --data-binary '{ - "federation": {}, - "queries": [ - { - "indexUid": "chats", - "q": "rotondo" - }, - { - "indexUid": "profiles", - "q": "rotondo", - "federationOptions": { - "weight": 1.2 - } - }, - { - "indexUid": "tickets", - "q": "rotondo" - } - ] - }' -``` + This request will lead to results from the query targeting `profile` ranking higher than documents from other queries: diff --git a/learn/personalization/making_personalized_search_queries.mdx b/learn/personalization/making_personalized_search_queries.mdx index 207b97c8a6..bb7c78c3ee 100644 --- a/learn/personalization/making_personalized_search_queries.mdx +++ b/learn/personalization/making_personalized_search_queries.mdx @@ -3,6 +3,8 @@ title: Performing personalized search queries description: Search personalization uses context about the person performing the search to provide results more relevant to that specific user. This article guides you through configuring and performing personalized search queries. --- +import CodeSamplesPersonalizationSearch1 from '/snippets/generated-code-samples/code_samples_personalization_search_1.mdx'; + ## Requirements - A Meilisearch project @@ -41,14 +43,4 @@ Once search personalization is active and you have a pipeline in place to genera Submit a search query and include the `personalize` search parameter. `personalize` must be an object with a single field, `userContext`. Use the description you generated in the previous step as the value for `userContext`: -```sh -curl \ - -X POST 'MEILISEARCH_URL/indexes/INDEX_NAME/search' \ - -H 'Content-Type: application/json' \ - --data-binary '{ - "q": "wireless keyboard", - "personalize": { - "userContext": "The user prefers compact mechanical keyboards from Keychron or Logitech, with a mid-range budget and quiet keys for remote work." - } - }' -``` + diff --git a/learn/security/basic_security.mdx b/learn/security/basic_security.mdx index b297fa19b2..594bb95790 100644 --- a/learn/security/basic_security.mdx +++ b/learn/security/basic_security.mdx @@ -5,7 +5,7 @@ description: This tutorial will show you how to secure your Meilisearch project. --- import CodeSamplesBasicSecurityTutorialAdmin1 from '/snippets/generated-code-samples/code_samples_basic_security_tutorial_admin_1.mdx'; -import CodeSamplesBasicSecurityTutorialListing1 from '/snippets/generated-code-samples/code_samples_basic_security_tutorial_listing_1.mdx'; +import CodeSamplesAuthorizationHeader1 from '/snippets/generated-code-samples/code_samples_authorization_header_1.mdx'; import CodeSamplesBasicSecurityTutorialSearch1 from '/snippets/generated-code-samples/code_samples_basic_security_tutorial_search_1.mdx'; This tutorial will show you how to secure your Meilisearch project. You will see how to manage your master key and how to safely send requests to the Meilisearch API using an API key. @@ -97,7 +97,7 @@ Find your API keys by visiting your project settings, then clicking "API Keys" o Use your master key to query the `/keys` endpoint to view all API keys in your instance: - + Only use the master key to manage API keys. Never use the master key to perform searches or other common operations. diff --git a/learn/security/generate_tenant_token_scratch.mdx b/learn/security/generate_tenant_token_scratch.mdx index 2df19ce1f0..5c362e8d55 100644 --- a/learn/security/generate_tenant_token_scratch.mdx +++ b/learn/security/generate_tenant_token_scratch.mdx @@ -4,6 +4,7 @@ sidebarTitle: Generate a tenant token without a library description: This guide shows you the main steps when creating tenant tokens without using any libraries. --- +import CodeSamplesAuthorizationHeader1 from '/snippets/generated-code-samples/code_samples_authorization_header_1.mdx'; import CodeSamplesTenantTokenGuideSearchNoSdk1 from '/snippets/generated-code-samples/code_samples_tenant_token_guide_search_no_sdk_1.mdx'; Generating tenant tokens without a library is possible, but not recommended. This guide summarizes the necessary steps. @@ -33,13 +34,9 @@ First, create a set of search rules: } ``` -Next, find your default search API key. Query the [get an API key endpoint](/reference/api/keys/get-api-key) and inspect the `uid` field to obtain your API key's UID: +Next, find your default search API key. Query the [get API keys endpoint](/reference/api/keys/get-api-key) and inspect the `uid` field to obtain your API key's UID: -```sh -curl \ - -X GET 'MEILISEARCH_URL/keys/API_KEY' \ - -H 'Authorization: Bearer MASTER_KEY' -``` + For maximum security, you should also set an expiry date for your tenant tokens. The following Node.js example configures the token to expire 20 minutes after its creation: diff --git a/learn/security/generate_tenant_token_sdk.mdx b/learn/security/generate_tenant_token_sdk.mdx index 09a5349cc4..54065e69d2 100644 --- a/learn/security/generate_tenant_token_sdk.mdx +++ b/learn/security/generate_tenant_token_sdk.mdx @@ -4,6 +4,7 @@ sidebarTitle: Generate tenant tokens with an official SDK description: This guide shows you the main steps when creating tenant tokens using Meilisearch's official SDKs. --- +import CodeSamplesAuthorizationHeader1 from '/snippets/generated-code-samples/code_samples_authorization_header_1.mdx'; import CodeSamplesTenantTokenGuideGenerateSdk1 from '/snippets/generated-code-samples/code_samples_tenant_token_guide_generate_sdk_1.mdx'; import CodeSamplesTenantTokenGuideSearchSdk1 from '/snippets/generated-code-samples/code_samples_tenant_token_guide_search_sdk_1.mdx'; @@ -29,13 +30,9 @@ First, import the SDK. Then create a set of [search rules](/learn/security/tenan Search rules must be an object where each key corresponds to an index in your instance. You may configure any number of filters for each index. -Next, find your default search API key. Query the [get an API key endpoint](/reference/api/keys/get-api-key) and inspect the `uid` field to obtain your API key's UID: +Next, find your default search API key. Query the [get API keys endpoint](/reference/api/keys/get-api-key) and inspect the `uid` field to obtain your API key's UID: -```sh -curl \ - -X GET 'MEILISEARCH_URL/keys/API_KEY' \ - -H 'Authorization: Bearer MASTER_KEY' -``` + For maximum security, you should also define an expiry date for tenant tokens. diff --git a/learn/security/generate_tenant_token_third_party.mdx b/learn/security/generate_tenant_token_third_party.mdx index 80e50e5fff..7da8e0d7f3 100644 --- a/learn/security/generate_tenant_token_third_party.mdx +++ b/learn/security/generate_tenant_token_third_party.mdx @@ -4,6 +4,7 @@ sidebarTitle: Generate tenant tokens without a Meilisearch SDK description: This guide shows you the main steps when creating tenant tokens without using Meilisearch's official SDKs. --- +import CodeSamplesAuthorizationHeader1 from '/snippets/generated-code-samples/code_samples_authorization_header_1.mdx'; import CodeSamplesTenantTokenGuideSearchNoSdk1 from '/snippets/generated-code-samples/code_samples_tenant_token_guide_search_no_sdk_1.mdx'; This guide shows you the main steps when creating tenant tokens using [`node-jsonwebtoken`](https://www.npmjs.com/package/jsonwebtoken), a third-party library. @@ -28,13 +29,9 @@ First, create a set of search rules: } ``` -Next, find your default search API key. Query the [get an API key endpoint](/reference/api/keys/get-api-key) and inspect the `uid` field to obtain your API key's UID: +Next, find your default search API key. Query the [get API keys endpoint](/reference/api/keys/get-api-key) and inspect the `uid` field to obtain your API key's UID: -```sh -curl \ - -X GET 'MEILISEARCH_URL/keys/API_KEY' \ - -H 'Authorization: Bearer MASTER_KEY' -``` + For maximum security, you should also set an expiry date for your tenant tokens. The following example configures the token to expire 20 minutes after its creation: diff --git a/learn/update_and_migration/migrating_cloud.mdx b/learn/update_and_migration/migrating_cloud.mdx index ad54c44a87..8d1193f8ee 100644 --- a/learn/update_and_migration/migrating_cloud.mdx +++ b/learn/update_and_migration/migrating_cloud.mdx @@ -4,6 +4,8 @@ sidebarTitle: Migrating to Meilisearch Cloud description: Meilisearch Cloud is the recommended way of using Meilisearch. This guide walks you through migrating Meilisearch from a self-hosted installation to Meilisearch Cloud. --- +import CodeSamplesPostDump1 from '/snippets/generated-code-samples/code_samples_post_dump_1.mdx'; + Meilisearch Cloud is the recommended way of using Meilisearch. This guide walks you through migrating Meilisearch from a self-hosted installation to Meilisearch Cloud. ## Requirements @@ -20,9 +22,7 @@ To migrate Meilisearch, you must first [export a dump](/learn/data_backup/dumps) To export a dump, make sure your self-hosted Meilisearch instance is running. Then, open your terminal and run the following command, replacing `MEILISEARCH_URL` with your instance's address: -```sh -curl -X POST 'MEILISEARCH_URL:7700/dumps' -``` + Meilisearch will return a summarized task object and begin creating the dump. [Use the returned object's `taskUid` to monitor its progress.](/learn/async/asynchronous_operations) diff --git a/learn/update_and_migration/updating.mdx b/learn/update_and_migration/updating.mdx index f6caea56c2..6d3939ecbd 100644 --- a/learn/update_and_migration/updating.mdx +++ b/learn/update_and_migration/updating.mdx @@ -9,6 +9,7 @@ import { NoticeTag } from '/snippets/notice_tag.mdx'; import CodeSamplesUpdatingGuideCheckVersionNewAuthorizationHeader from '/snippets/generated-code-samples/code_samples_updating_guide_check_version_new_authorization_header.mdx'; import CodeSamplesUpdatingGuideCreateDump from '/snippets/generated-code-samples/code_samples_updating_guide_create_dump.mdx'; +import CodeSamplesCreateSnapshot1 from '/snippets/generated-code-samples/code_samples_create_snapshot_1.mdx'; Currently, Meilisearch databases are only compatible with the version of Meilisearch used to create them. The following guide will walk you through using a [dump](/learn/data_backup/dumps) to migrate an existing database from an older version of Meilisearch to the most recent one. @@ -50,10 +51,7 @@ Dumpless upgrades are available when upgrading from Meilisearch >=v1.12 to Meili Dumpless upgrades are an experimental feature. Because of that, it may in rare occasions partially fail and result in a corrupted database. To prevent data loss, create a snapshot of your instance: -```sh -curl \ - -X POST 'MEILISEARCH_URL/snapshots' -``` + Meilisearch will respond with a partial task object. Use its `taskUid` to monitor the snapshot creation status. Once the task is completed, proceed to the next step. diff --git a/snippets/generated-code-samples/code_samples_ai_search_getting_started_embedders_1.mdx b/snippets/generated-code-samples/code_samples_ai_search_getting_started_embedders_1.mdx new file mode 100644 index 0000000000..1fd0e0b35c --- /dev/null +++ b/snippets/generated-code-samples/code_samples_ai_search_getting_started_embedders_1.mdx @@ -0,0 +1,16 @@ + + +```bash cURL +curl \ + -X PATCH 'MEILISEARCH_URL/indexes/kitchenware/settings/embedders' \ + -H 'Content-Type: application/json' \ + --data-binary '{ + "products-openai": { + "source": "openAi", + "apiKey": "OPEN_AI_API_KEY", + "model": "text-embedding-3-small", + "documentTemplate": "An object used in a kitchen named '\''{{doc.name}}'\''" + } + }' +``` + \ No newline at end of file diff --git a/snippets/generated-code-samples/code_samples_ai_search_getting_started_search_1.mdx b/snippets/generated-code-samples/code_samples_ai_search_getting_started_search_1.mdx new file mode 100644 index 0000000000..548d6c3222 --- /dev/null +++ b/snippets/generated-code-samples/code_samples_ai_search_getting_started_search_1.mdx @@ -0,0 +1,14 @@ + + +```bash cURL +curl \ + -X POST 'MEILISEARCH_URL/indexes/kitchenware/search' \ + -H 'Content-Type: application/json' \ + --data-binary '{ + "q": "kitchen utensils made of wood", + "hybrid": { + "embedder": "products-openai" + } + }' +``` + \ No newline at end of file diff --git a/snippets/generated-code-samples/code_samples_ai_search_user_embeddings_documents_1.mdx b/snippets/generated-code-samples/code_samples_ai_search_user_embeddings_documents_1.mdx new file mode 100644 index 0000000000..11a6d1d2e1 --- /dev/null +++ b/snippets/generated-code-samples/code_samples_ai_search_user_embeddings_documents_1.mdx @@ -0,0 +1,12 @@ + + +```bash cURL +curl \ + -X POST 'MEILISEARCH_URL/indexes/INDEX_NAME/documents' \ + -H 'Content-Type: application/json' \ + --data-binary '[ + { "id": 0, "_vectors": { "EMBEDDER_NAME": [0, 0.8, -0.2]}, "text": "frying pan" }, + { "id": 1, "_vectors": { "EMBEDDER_NAME": [1, -0.2, 0]}, "text": "baking dish" } + ]' +``` + \ No newline at end of file diff --git a/snippets/generated-code-samples/code_samples_ai_search_user_embeddings_search_vector_filter_1.mdx b/snippets/generated-code-samples/code_samples_ai_search_user_embeddings_search_vector_filter_1.mdx new file mode 100644 index 0000000000..0c3d44c133 --- /dev/null +++ b/snippets/generated-code-samples/code_samples_ai_search_user_embeddings_search_vector_filter_1.mdx @@ -0,0 +1,16 @@ + + +```bash cURL +curl \ + -X POST 'MEILISEARCH_URL/indexes/INDEX_NAME/search' \ + -H 'Content-Type: application/json' \ + --data-binary '{ + "vector": [0, 1, 2], + "filter": "price < 10", + "sort": ["price:asc"], + "hybrid": { + "embedder": "EMBEDDER_NAME" + } + }' +``` + \ No newline at end of file diff --git a/snippets/generated-code-samples/code_samples_authorization_header_1.mdx b/snippets/generated-code-samples/code_samples_authorization_header_1.mdx index 97607e267c..6c22f92648 100644 --- a/snippets/generated-code-samples/code_samples_authorization_header_1.mdx +++ b/snippets/generated-code-samples/code_samples_authorization_header_1.mdx @@ -1,7 +1,6 @@ ```bash cURL -# replace the MASTER_KEY placeholder with your master key curl \ -X GET 'MEILISEARCH_URL/keys' \ -H 'Authorization: Bearer MASTER_KEY' diff --git a/snippets/generated-code-samples/code_samples_basic_security_tutorial_listing_1.mdx b/snippets/generated-code-samples/code_samples_basic_security_tutorial_listing_1.mdx index a9d2c5be09..2c9e058257 100644 --- a/snippets/generated-code-samples/code_samples_basic_security_tutorial_listing_1.mdx +++ b/snippets/generated-code-samples/code_samples_basic_security_tutorial_listing_1.mdx @@ -1,10 +1,5 @@ -```bash cURL -curl -X GET 'MEILISEARCH_URL/keys' \ --H 'Authorization: Bearer MASTER_KEY' -``` - ```rust Rust let client = Client::new("http://localhost:7700", Some("MASTER_KEY")); client diff --git a/snippets/generated-code-samples/code_samples_chat_completions_1.mdx b/snippets/generated-code-samples/code_samples_chat_completions_1.mdx new file mode 100644 index 0000000000..bb22439b0d --- /dev/null +++ b/snippets/generated-code-samples/code_samples_chat_completions_1.mdx @@ -0,0 +1,34 @@ + + +```bash cURL +curl -N \ + -X POST 'MEILISEARCH_URL/chats/WORKSPACE_NAME/chat/completions' \ + -H 'Authorization: Bearer MEILISEARCH_API_KEY' \ + -H 'Content-Type: application/json' \ + --data-binary '{ + "model": "PROVIDER_MODEL_UID", + "messages": [ + { + "role": "user", + "content": "USER_PROMPT" + } + ], + "tools": [ + { + "type": "function", + "function": { + "name": "_meiliSearchProgress", + "description": "Reports real-time search progress to the user" + } + }, + { + "type": "function", + "function": { + "name": "_meiliSearchSources", + "description": "Provides sources and references for the information" + } + } + ] + }' +``` + \ No newline at end of file diff --git a/snippets/generated-code-samples/code_samples_chat_create_key_1.mdx b/snippets/generated-code-samples/code_samples_chat_create_key_1.mdx new file mode 100644 index 0000000000..326729a33b --- /dev/null +++ b/snippets/generated-code-samples/code_samples_chat_create_key_1.mdx @@ -0,0 +1,16 @@ + + +```bash cURL +curl \ + -X POST 'MEILISEARCH_URL/keys' \ + -H 'Authorization: Bearer MEILISEARCH_KEY' \ + -H 'Content-Type: application/json' \ + --data-binary '{ + "name": "Chat API Key", + "description": "API key for chat completions", + "actions": ["search", "chatCompletions"], + "indexes": ["*"], + "expiresAt": null + }' +``` + \ No newline at end of file diff --git a/snippets/generated-code-samples/code_samples_chat_get_settings_1.mdx b/snippets/generated-code-samples/code_samples_chat_get_settings_1.mdx new file mode 100644 index 0000000000..af2da007f6 --- /dev/null +++ b/snippets/generated-code-samples/code_samples_chat_get_settings_1.mdx @@ -0,0 +1,8 @@ + + +```bash cURL +curl \ + -X GET 'MEILISEARCH_URL/chats/WORKSPACE_NAME/settings' \ + -H "Authorization: Bearer MEILISEARCH_KEY" +``` + \ No newline at end of file diff --git a/snippets/generated-code-samples/code_samples_chat_index_settings_1.mdx b/snippets/generated-code-samples/code_samples_chat_index_settings_1.mdx new file mode 100644 index 0000000000..d4b69a760b --- /dev/null +++ b/snippets/generated-code-samples/code_samples_chat_index_settings_1.mdx @@ -0,0 +1,16 @@ + + +```bash cURL +curl \ + -X PATCH 'MEILISEARCH_URL/indexes/INDEX_NAME/settings' \ + -H 'Authorization: Bearer MEILISEARCH_KEY' \ + -H 'Content-Type: application/json' \ + --data-binary '{ + "chat": { + "description": "A comprehensive database of TYPE_OF_DOCUMENT containing titles, descriptions, genres, and release dates to help users searching for TYPE_OF_DOCUMENT", + "documentTemplate": "{% for field in fields %}{% if field.is_searchable and field.value != nil %}{{ field.name }}: {{ field.value }}\n{% endif %}{% endfor %}", + "documentTemplateMaxBytes": 400 + } + }' +``` + \ No newline at end of file diff --git a/snippets/generated-code-samples/code_samples_chat_patch_settings_1.mdx b/snippets/generated-code-samples/code_samples_chat_patch_settings_1.mdx new file mode 100644 index 0000000000..d673a2f98a --- /dev/null +++ b/snippets/generated-code-samples/code_samples_chat_patch_settings_1.mdx @@ -0,0 +1,10 @@ + + +```bash cURL +curl \ + -X PATCH 'MEILISEARCH_URL/chats/WORKSPACE_NAME/settings' \ + -H "Authorization: Bearer MEILISEARCH_KEY" \ + -H "Content-Type: application/json" \ + --data-binary '{ "apiKey": "your-valid-api-key" }' +``` + \ No newline at end of file diff --git a/snippets/generated-code-samples/code_samples_configure_rest_embedder_1.mdx b/snippets/generated-code-samples/code_samples_configure_rest_embedder_1.mdx new file mode 100644 index 0000000000..281189680b --- /dev/null +++ b/snippets/generated-code-samples/code_samples_configure_rest_embedder_1.mdx @@ -0,0 +1,26 @@ + + +```bash cURL +curl \ + -X PATCH 'MEILISEARCH_URL/indexes/INDEX_NAME/settings/embedders' \ + -H 'Content-Type: application/json' \ + --data-binary '{ + "EMBEDDER_NAME": { + "source": "rest", + "url": "PROVIDER_URL", + "request": { + "model": "MODEL_NAME", + "input": ["{{text}}", "{{..}}"] + }, + "response": { + "data": [ + { "embedding": "{{embedding}}" }, + "{{..}}" + ] + }, + "apiKey": "PROVIDER_API_KEY", + "documentTemplate": "SHORT_AND_RELEVANT_DOCUMENT_TEMPLATE" + } + }' +``` + \ No newline at end of file diff --git a/snippets/generated-code-samples/code_samples_date_guide_index_1.mdx b/snippets/generated-code-samples/code_samples_date_guide_index_1.mdx index 4f89b156e7..8f2348baaf 100644 --- a/snippets/generated-code-samples/code_samples_date_guide_index_1.mdx +++ b/snippets/generated-code-samples/code_samples_date_guide_index_1.mdx @@ -2,8 +2,8 @@ ```bash cURL curl \ - -x POST 'MEILISEARCH_URL/indexes/games/documents' \ - -h 'content-type: application/json' \ + -X POST 'MEILISEARCH_URL/indexes/games/documents' \ + -H 'Content-Type: application/json' \ --data-binary @games.json ``` diff --git a/snippets/generated-code-samples/code_samples_federated_search_multi_search_1.mdx b/snippets/generated-code-samples/code_samples_federated_search_multi_search_1.mdx new file mode 100644 index 0000000000..a2972f4a69 --- /dev/null +++ b/snippets/generated-code-samples/code_samples_federated_search_multi_search_1.mdx @@ -0,0 +1,25 @@ + + +```bash cURL +curl \ + -X POST 'MEILISEARCH_URL/multi-search' \ + -H 'Content-Type: application/json' \ + --data-binary '{ + "federation": {}, + "queries": [ + { + "indexUid": "chats", + "q": "natasha" + }, + { + "indexUid": "profiles", + "q": "natasha" + }, + { + "indexUid": "tickets", + "q": "natasha" + } + ] + }' +``` + \ No newline at end of file diff --git a/snippets/generated-code-samples/code_samples_federated_search_multi_search_weight_1.mdx b/snippets/generated-code-samples/code_samples_federated_search_multi_search_weight_1.mdx new file mode 100644 index 0000000000..30ebe95c05 --- /dev/null +++ b/snippets/generated-code-samples/code_samples_federated_search_multi_search_weight_1.mdx @@ -0,0 +1,26 @@ + + +```bash cURL +curl \ + -X POST 'MEILISEARCH_URL/multi-search' \ + -H 'Content-Type: application/json' \ + --data-binary '{ + "federation": {}, + "queries": [ + { + "indexUid": "chats", + "q": "rotondo" + }, + { + "indexUid": "profiles", + "q": "rotondo", + "federationOptions": { "weight": 1.2 } + }, + { + "indexUid": "tickets", + "q": "rotondo" + } + ] + }' +``` + \ No newline at end of file diff --git a/snippets/generated-code-samples/code_samples_image_search_multimodal_search_image_1.mdx b/snippets/generated-code-samples/code_samples_image_search_multimodal_search_image_1.mdx new file mode 100644 index 0000000000..a0d130e644 --- /dev/null +++ b/snippets/generated-code-samples/code_samples_image_search_multimodal_search_image_1.mdx @@ -0,0 +1,19 @@ + + +```bash cURL +curl \ + -X POST 'MEILISEARCH_URL/indexes/INDEX_NAME/search' \ + -H 'Content-Type: application/json' \ + --data-binary '{ + "media": { + "image": { + "mime": "image/jpeg", + "data": "" + } + }, + "hybrid": { + "embedder": "MULTIMODAL_EMBEDDER_NAME" + } + }' +``` + \ No newline at end of file diff --git a/snippets/generated-code-samples/code_samples_image_search_multimodal_search_text_1.mdx b/snippets/generated-code-samples/code_samples_image_search_multimodal_search_text_1.mdx new file mode 100644 index 0000000000..9232273c4f --- /dev/null +++ b/snippets/generated-code-samples/code_samples_image_search_multimodal_search_text_1.mdx @@ -0,0 +1,14 @@ + + +```bash cURL +curl \ + -X POST 'MEILISEARCH_URL/indexes/INDEX_NAME/search' \ + -H 'Content-Type: application/json' \ + --data-binary '{ + "q": "a mountain sunset with snow", + "hybrid": { + "embedder": "MULTIMODAL_EMBEDDER_NAME" + } + }' +``` + \ No newline at end of file diff --git a/snippets/generated-code-samples/code_samples_image_search_multimodal_settings_1.mdx b/snippets/generated-code-samples/code_samples_image_search_multimodal_settings_1.mdx new file mode 100644 index 0000000000..46f85017b9 --- /dev/null +++ b/snippets/generated-code-samples/code_samples_image_search_multimodal_settings_1.mdx @@ -0,0 +1,71 @@ + + +```bash cURL +curl \ + -X PATCH 'MEILISEARCH_URL/indexes/INDEX_NAME/settings' \ + -H 'Content-Type: application/json' \ + --data-binary '{ + "embedders": { + "MULTIMODAL_EMBEDDER_NAME": { + "source": "rest", + "url": "https://api.voyageai.com/v1/multimodal-embeddings", + "apiKey": "VOYAGE_API_KEY", + "indexingFragments": { + "TEXTUAL_FRAGMENT_NAME": { + "value": { + "content": [ + { + "type": "text", + "text": "A document named {{doc.title}} described as {{doc.description}}" + } + ] + } + }, + "IMAGE_FRAGMENT_NAME": { + "value": { + "content": [ + { + "type": "image_url", + "image_url": "{{doc.poster_url}}" + } + ] + } + } + }, + "searchFragments": { + "USER_TEXT_FRAGMENT": { + "value": { + "content": [ + { + "type": "text", + "text": "{{q}}" + } + ] + } + }, + "USER_SUBMITTED_IMAGE_FRAGMENT": { + "value": { + "content": [ + { + "type": "image_base64", + "image_base64": "data:{{media.image.mime}};base64,{{media.image.data}}" + } + ] + } + } + }, + "request": { + "inputs": ["{{fragment}}", "{{..}}"], + "model": "voyage-multimodal-3" + }, + "response": { + "data": [ + { "embedding": "{{embedding}}" }, + "{{..}}" + ] + } + } + } + }' +``` + \ No newline at end of file diff --git a/snippets/generated-code-samples/code_samples_image_search_user_embeddings_search_1.mdx b/snippets/generated-code-samples/code_samples_image_search_user_embeddings_search_1.mdx new file mode 100644 index 0000000000..e4af62225c --- /dev/null +++ b/snippets/generated-code-samples/code_samples_image_search_user_embeddings_search_1.mdx @@ -0,0 +1,12 @@ + + +```bash cURL +curl \ + -X POST 'MEILISEARCH_URL/indexes/INDEX_NAME/search' \ + -H 'Content-Type: application/json' \ + --data-binary '{ + "vector": VECTORIZED_QUERY, + "hybrid": { "embedder": "EMBEDDER_NAME" } + }' +``` + \ No newline at end of file diff --git a/snippets/generated-code-samples/code_samples_image_search_user_embeddings_search_q_1.mdx b/snippets/generated-code-samples/code_samples_image_search_user_embeddings_search_q_1.mdx new file mode 100644 index 0000000000..04f215738e --- /dev/null +++ b/snippets/generated-code-samples/code_samples_image_search_user_embeddings_search_q_1.mdx @@ -0,0 +1,13 @@ + + +```bash cURL +curl \ + -X POST 'MEILISEARCH_URL/indexes/INDEX_NAME/search' \ + -H 'Content-Type: application/json' \ + --data-binary '{ + "vector": VECTORIZED_QUERY, + "hybrid": { "embedder": "EMBEDDER_NAME" }, + "q": "QUERY" + }' +``` + \ No newline at end of file diff --git a/snippets/generated-code-samples/code_samples_multilingual_dataset_guide_update_localized_attributes_1.mdx b/snippets/generated-code-samples/code_samples_multilingual_dataset_guide_update_localized_attributes_1.mdx new file mode 100644 index 0000000000..e6a4efc98c --- /dev/null +++ b/snippets/generated-code-samples/code_samples_multilingual_dataset_guide_update_localized_attributes_1.mdx @@ -0,0 +1,13 @@ + + +```bash cURL +curl \ + -X PUT 'MEILISEARCH_URL/indexes/INDEX_NAME/settings/localized-attributes' \ + -H 'Content-Type: application/json' \ + --data-binary '[ + { "attributePatterns": ["*_en"], "locales": ["eng"] }, + { "attributePatterns": ["*_de"], "locales": ["deu"] }, + { "attributePatterns": ["*_fr"], "locales": ["fra"] } + ]' +``` + \ No newline at end of file diff --git a/snippets/generated-code-samples/code_samples_personalization_search_1.mdx b/snippets/generated-code-samples/code_samples_personalization_search_1.mdx new file mode 100644 index 0000000000..73522d6c7e --- /dev/null +++ b/snippets/generated-code-samples/code_samples_personalization_search_1.mdx @@ -0,0 +1,14 @@ + + +```bash cURL +curl \ + -X POST 'MEILISEARCH_URL/indexes/INDEX_NAME/search' \ + -H 'Content-Type: application/json' \ + --data-binary '{ + "q": "wireless keyboard", + "personalize": { + "userContext": "The user prefers compact mechanical keyboards from Keychron or Logitech, with a mid-range budget and quiet keys for remote work." + } + }' +``` + \ No newline at end of file diff --git a/snippets/generated-code-samples/code_samples_search_parameter_guide_hybrid_1.mdx b/snippets/generated-code-samples/code_samples_search_parameter_guide_hybrid_1.mdx index e61487848d..177aa4eea1 100644 --- a/snippets/generated-code-samples/code_samples_search_parameter_guide_hybrid_1.mdx +++ b/snippets/generated-code-samples/code_samples_search_parameter_guide_hybrid_1.mdx @@ -2,7 +2,7 @@ ```bash cURL curl -X POST 'MEILISEARCH_URL/indexes/INDEX_NAME/search' \ - -H 'content-type: application/json' \ + -H 'Content-Type: application/json' \ --data-binary '{ "q": "kitchen utensils", "hybrid": { diff --git a/snippets/generated-code-samples/code_samples_search_parameter_guide_vector_1.mdx b/snippets/generated-code-samples/code_samples_search_parameter_guide_vector_1.mdx index 029c39804d..eb0667a074 100644 --- a/snippets/generated-code-samples/code_samples_search_parameter_guide_vector_1.mdx +++ b/snippets/generated-code-samples/code_samples_search_parameter_guide_vector_1.mdx @@ -2,7 +2,7 @@ ```bash cURL curl -X POST 'MEILISEARCH_URL/indexes/INDEX_NAME/search' \ - -H 'content-type: application/json' \ + -H 'Content-Type: application/json' \ --data-binary '{ "vector": [0, 1, 2], "hybrid": { diff --git a/snippets/generated-code-samples/code_samples_search_parameter_reference_retrieve_vectors_1.mdx b/snippets/generated-code-samples/code_samples_search_parameter_reference_retrieve_vectors_1.mdx index 76d35183c8..c2e2bfbb27 100644 --- a/snippets/generated-code-samples/code_samples_search_parameter_reference_retrieve_vectors_1.mdx +++ b/snippets/generated-code-samples/code_samples_search_parameter_reference_retrieve_vectors_1.mdx @@ -2,7 +2,7 @@ ```bash cURL curl -X POST 'MEILISEARCH_URL/indexes/INDEX_NAME/search' \ - -H 'content-type: application/json' \ + -H 'Content-Type: application/json' \ --data-binary '{ "q": "kitchen utensils", "retrieveVectors": true, diff --git a/snippets/generated-code-samples/code_samples_update_experimental_features_chat_1.mdx b/snippets/generated-code-samples/code_samples_update_experimental_features_chat_1.mdx new file mode 100644 index 0000000000..62423ede34 --- /dev/null +++ b/snippets/generated-code-samples/code_samples_update_experimental_features_chat_1.mdx @@ -0,0 +1,11 @@ + + +```bash cURL +curl \ + -X PATCH 'MEILISEARCH_URL/experimental-features/' \ + -H 'Content-Type: application/json' \ + --data-binary '{ + "chatCompletions": true + }' +``` + \ No newline at end of file diff --git a/snippets/generated-code-samples/code_samples_update_experimental_features_contains_1.mdx b/snippets/generated-code-samples/code_samples_update_experimental_features_contains_1.mdx new file mode 100644 index 0000000000..adf6d3b38e --- /dev/null +++ b/snippets/generated-code-samples/code_samples_update_experimental_features_contains_1.mdx @@ -0,0 +1,11 @@ + + +```bash cURL +curl \ + -X PATCH 'MEILISEARCH_URL/experimental-features/' \ + -H 'Content-Type: application/json' \ + --data-binary '{ + "containsFilter": true + }' +``` + \ No newline at end of file diff --git a/snippets/generated-code-samples/code_samples_update_experimental_features_multimodal_1.mdx b/snippets/generated-code-samples/code_samples_update_experimental_features_multimodal_1.mdx new file mode 100644 index 0000000000..abf3881f91 --- /dev/null +++ b/snippets/generated-code-samples/code_samples_update_experimental_features_multimodal_1.mdx @@ -0,0 +1,11 @@ + + +```bash cURL +curl \ + -X PATCH 'MEILISEARCH_URL/experimental-features/' \ + -H 'Content-Type: application/json' \ + --data-binary '{ + "multimodal": true + }' +``` + \ No newline at end of file diff --git a/snippets/generated-code-samples/code_samples_user_provided_embeddings_settings_1.mdx b/snippets/generated-code-samples/code_samples_user_provided_embeddings_settings_1.mdx new file mode 100644 index 0000000000..0ec00f7693 --- /dev/null +++ b/snippets/generated-code-samples/code_samples_user_provided_embeddings_settings_1.mdx @@ -0,0 +1,16 @@ + + +```bash cURL +curl \ + -X PATCH 'MEILISEARCH_URL/indexes/INDEX_NAME/settings' \ + -H 'Content-Type: application/json' \ + --data-binary '{ + "embedders": { + "EMBEDDER_NAME": { + "source": "userProvided", + "dimensions": MODEL_DIMENSIONS + } + } + }' +``` + \ No newline at end of file