### Install Go SDK Source: https://www.meilisearch.com/docs/getting_started/sdks/go Install the Meilisearch Go SDK using the go get command. Ensure you have Go 1.16 or higher installed. ```bash go get github.com/meilisearch/meilisearch-go ``` -------------------------------- ### Full Request Example with OpenAI SDK Source: https://www.meilisearch.com/docs/capabilities/conversational_search/advanced/chat_tooling_reference Demonstrates how to configure and use the OpenAI SDK to interact with Meilisearch for chat completions. Ensure you have the OpenAI SDK installed and replace placeholders with your actual Meilisearch URL and API key. ```javascript import OpenAI from 'openai'; const client = new OpenAI({ baseURL: 'MEILISEARCH_URL/chats/WORKSPACE_NAME', apiKey: 'MEILISEARCH_KEY', }); const tools = [ { type: 'function', function: { name: '_meiliSearchProgress', description: 'Provides information about the current Meilisearch search operation', parameters: { type: 'object', properties: { call_id: { type: 'string' }, function_name: { type: 'string' }, function_parameters: { type: 'string' }, }, required: ['call_id', 'function_name', 'function_parameters'], additionalProperties: false, }, strict: true, }, }, { type: 'function', function: { name: '_meiliAppendConversationMessage', description: 'Append a new message to the conversation based on what happened internally', parameters: { type: 'object', properties: { role: { type: 'string' }, content: { type: 'string' }, tool_calls: { type: ['array', 'null'], items: { type: 'object', properties: { function: { type: 'object', properties: { name: { type: 'string' }, arguments: { type: 'string' } } }, id: { type: 'string' }, type: { type: 'string' } } } }, tool_call_id: { type: ['string', 'null'] }, }, required: ['role', 'content', 'tool_calls', 'tool_call_id'], additionalProperties: false, }, strict: true, }, }, { type: 'function', function: { name: '_meiliSearchSources', description: 'Provides sources of the search', parameters: { type: 'object', properties: { call_id: { type: 'string' }, documents: { type: 'array', items: { type: 'object' } }, }, required: ['call_id', 'documents'], additionalProperties: false, }, strict: true, }, }, ]; const stream = await client.chat.completions.create({ model: 'PROVIDER_MODEL_UID', messages: [{ role: 'user', content: 'What are the best sci-fi movies?' }], tools, stream: true, }); for await (const chunk of stream) { const content = chunk.choices[0]?.delta?.content; if (content) process.stdout.write(content); } ``` -------------------------------- ### Install React InstantSearch and Meilisearch Client Source: https://www.meilisearch.com/docs/getting_started/instant_meilisearch/react Install the necessary libraries for React InstantSearch and the Meilisearch connector. ```bash npm install react-instantsearch @meilisearch/instant-meilisearch instantsearch.css ``` -------------------------------- ### Enable and Start Meilisearch Service Source: https://www.meilisearch.com/docs/resources/self_hosting/deployment/digitalocean Reloads systemd, enables the Meilisearch service to start on boot, and then starts the service immediately. ```bash systemctl daemon-reload systemctl enable meilisearch systemctl start meilisearch ``` -------------------------------- ### Install Nginx on Ubuntu Source: https://www.meilisearch.com/docs/resources/self_hosting/deployment/aws Installs Nginx on Ubuntu systems using apt. ```bash sudo apt install nginx -y ``` -------------------------------- ### Enable and Start Meilisearch Service Source: https://www.meilisearch.com/docs/resources/self_hosting/deployment/running_production Enables the Meilisearch service to start automatically on boot and then starts the service immediately. ```bash systemctl enable meilisearch systemctl start meilisearch ``` -------------------------------- ### Start React Development Server Source: https://www.meilisearch.com/docs/getting_started/instant_meilisearch/react Run the command to start the development server for your React application. ```bash npm run dev ``` -------------------------------- ### Install Nginx Source: https://www.meilisearch.com/docs/resources/self_hosting/deployment/digitalocean Installs the Nginx web server on your system. This is a prerequisite for setting up a reverse proxy. ```bash apt-get install nginx -y ``` -------------------------------- ### Install Nginx Source: https://www.meilisearch.com/docs/resources/self_hosting/deployment/gcp Install the Nginx web server, which will be used as a reverse proxy for Meilisearch. ```bash sudo apt install nginx -y ``` -------------------------------- ### Install Migration Dependencies Source: https://www.meilisearch.com/docs/resources/migration/supabase_migration Install the required Supabase and Meilisearch client libraries for JavaScript, Python, and Ruby. ```bash npm install -s @supabase/supabase-js meilisearch ``` ```bash pip install supabase meilisearch ``` ```bash gem install pg meilisearch ``` -------------------------------- ### Install Migration Dependencies Source: https://www.meilisearch.com/docs/resources/migration/elasticsearch_migration Install the Elasticsearch and Meilisearch libraries for your chosen programming language. ```bash npm install -s @elastic/elasticsearch meilisearch ``` ```bash pip install elasticsearch meilisearch ``` ```bash gem install elasticsearch meilisearch ``` -------------------------------- ### JSON Array Data Example Source: https://www.meilisearch.com/docs/getting_started/integrations/meilisearch_importer Example of a JSON file containing an array of product objects. ```json [ {"id": 1, "title": "Product A", "price": 29.99}, {"id": 2, "title": "Product B", "price": 39.99} ] ``` -------------------------------- ### Install Dart Dependencies Source: https://www.meilisearch.com/docs/getting_started/sdks/dart Run `dart pub get` or `flutter pub get` to install the project dependencies after updating pubspec.yaml. ```bash dart pub get # or for Flutter flutter pub get ``` -------------------------------- ### Full Example: Add Documents and Search Source: https://www.meilisearch.com/docs/getting_started/sdks/javascript A complete example demonstrating how to initialize the client, add documents, wait for the task, and perform a search. This showcases the typical workflow. ```javascript import { Meilisearch } from 'meilisearch' const client = new Meilisearch({ host: process.env.MEILISEARCH_URL, apiKey: process.env.MEILISEARCH_KEY }) async function main() { // Add documents const movies = [ { id: 1, title: 'The Matrix', genres: ['Action', 'Sci-Fi'], year: 1999 }, { id: 2, title: 'Inception', genres: ['Action', 'Thriller'], year: 2010 }, { id: 3, title: 'Interstellar', genres: ['Drama', 'Sci-Fi'], year: 2014 } ] const task = await client.index('movies').addDocuments(movies) await client.waitForTask(task.taskUid) // Search const results = await client.index('movies').search('inter') console.log(results.hits) } main() ``` -------------------------------- ### Full Example: Connect, Add Documents, and Search Source: https://www.meilisearch.com/docs/getting_started/sdks/python A comprehensive example demonstrating the entire process: connecting to Meilisearch, adding documents, and performing a search. It includes setting environment variables and waiting for tasks. ```python import meilisearch import os client = meilisearch.Client( os.environ.get('MEILISEARCH_URL'), os.environ.get('MEILISEARCH_KEY') ) # Add documents movies = [ {'id': 1, 'title': 'The Matrix', 'genres': ['Action', 'Sci-Fi'], 'year': 1999}, {'id': 2, 'title': 'Inception', 'genres': ['Action', 'Thriller'], 'year': 2010}, {'id': 3, 'title': 'Interstellar', 'genres': ['Drama', 'Sci-Fi'], 'year': 2014} ] task = client.index('movies').add_documents(movies) client.wait_for_task(task.task_uid) # Search results = client.index('movies').search('inter') print(results['hits']) ``` -------------------------------- ### Send Documents to Index via Go Source: https://www.meilisearch.com/docs/capabilities/indexing/getting_started Add documents to a Meilisearch index using the Go SDK. Install the SDK using `go get`. This example demonstrates reading a JSON file and sending the document data to the specified index. ```go // In the command line: // go get -u github.com/meilisearch/meilisearch-go // In your .go file: package main import ( "os" "encoding/json" "io" "github.com/meilisearch/meilisearch-go" ) func main() { client := meilisearch.New("MEILISEARCH_URL", meilisearch.WithAPIKey("masterKey")) jsonFile, _ := os.Open("movies.json") defer jsonFile.Close() byteValue, _ := io.ReadAll(jsonFile) var movies []map[string]interface{}("movies") json.Unmarshal(byteValue, &movies) _, err := client.Index("movies").AddDocuments(movies, nil) if err != nil { panic(err) } } ``` -------------------------------- ### Initialize Project Directory and Files (Python) Source: https://www.meilisearch.com/docs/resources/migration/algolia_migration Create a new project directory and initialize it with Python, creating a script file. ```bash mkdir algolia-meilisearch-migration cd algolia-meilisearch-migration touch script.py ``` -------------------------------- ### Initialize Project Directory and Files Source: https://www.meilisearch.com/docs/resources/migration/algolia_migration Create a new project directory and initialize it with npm, creating a script file for JavaScript. ```bash mkdir algolia-meilisearch-migration cd algolia-meilisearch-migration npm init -y touch script.js ``` -------------------------------- ### Install Latest Meilisearch Version Source: https://www.meilisearch.com/docs/resources/self_hosting/deployment/digitalocean Download and run the Meilisearch command-line installer script to install the latest version. This script ensures you get the correct binary for your system. ```bash # Install Meilisearch latest version from the script curl -L https://install.meilisearch.com | sh ``` -------------------------------- ### Initialize Project Directory and Files (Ruby) Source: https://www.meilisearch.com/docs/resources/migration/algolia_migration Create a new project directory and initialize it with Ruby, creating a script file. ```bash mkdir algolia-meilisearch-migration cd algolia-meilisearch-migration touch script.rb ``` -------------------------------- ### Basic Search with GET Source: https://www.meilisearch.com/docs/reference/api/search/search-with-get Perform a basic search query on an index using the GET method. This example searches for 'american ninja' in the 'movies' index. ```bash curl \ -X GET 'MEILISEARCH_URL/indexes/movies/search?q=american%20ninja' ``` -------------------------------- ### Get Faceting Settings (Empty Response Example) Source: https://www.meilisearch.com/docs/reference/api/settings/get-faceting This is an example of an empty JSON response, which might be returned if no specific faceting settings have been configured or if the index is new. ```json {} ``` -------------------------------- ### Full Example: Connect, Add Documents, and Search Source: https://www.meilisearch.com/docs/getting_started/sdks/java A complete Java example demonstrating connection to Meilisearch, adding documents, and performing a search query. ```java import com.meilisearch.sdk.*; import com.meilisearch.sdk.model.*; import com.google.gson.Gson; public class Main { public static void main(String[] args) throws Exception { // Connect Client client = new Client(new Config( System.getenv("MEILISEARCH_URL"), System.getenv("MEILISEARCH_KEY") )); // Add documents String documents = "[" + "{\"id\": 1, \"title\": \"The Matrix\", \"year\": 1999}," ``` ```java "{"id": 2, "title": "Inception", "year": 2010}," "{"id": 3, "title": "Interstellar", "year": 2014}" "]"; Index index = client.index("movies"); TaskInfo task = index.addDocuments(documents); client.waitForTask(task.getTaskUid()); // Search SearchResult results = index.search("inter"); System.out.println(results.getHits()); } } ``` -------------------------------- ### Initialize Project Directory Source: https://www.meilisearch.com/docs/resources/migration/elasticsearch_migration Create a new project directory and initialize it with npm, or create script files for Python and Ruby. ```bash mkdir elastic-meilisearch-migration cd elastic-meilisearch-migration npm init -y touch script.js ``` ```bash mkdir elastic-meilisearch-migration cd elastic-meilisearch-migration touch script.py ``` ```bash mkdir elastic-meilisearch-migration cd elastic-meilisearch-migration touch script.rb ``` -------------------------------- ### Install Dependencies for Vuepress Server Source: https://www.meilisearch.com/docs/resources/migration/previous_docs_version Install all necessary project packages for Meilisearch documentation versions v0.17-v1.1 using Yarn. This is a prerequisite for starting the local Vuepress server. ```bash yarn install ``` -------------------------------- ### Initialize Project Directory and Script File Source: https://www.meilisearch.com/docs/resources/migration/postgresql_migration Create a new project directory and an empty script file for your migration process. This is the first step for any language. ```bash mkdir pg-meilisearch-migration cd pg-meilisearch-migration npm init -y touch script.js ``` ```bash mkdir pg-meilisearch-migration cd pg-meilisearch-migration touch script.py ``` ```bash mkdir pg-meilisearch-migration cd pg-meilisearch-migration touch script.rb ``` -------------------------------- ### Get Network Topology Source: https://www.meilisearch.com/docs/resources/self_hosting/sharding/configure_replication Retrieve the current network topology to see configured remotes. This is useful for understanding the replication setup. ```bash curl \ -X GET 'MEILISEARCH_URL/network' \ -H 'Authorization: Bearer MEILISEARCH_KEY' ``` -------------------------------- ### Example Response for Distinct Attribute Source: https://www.meilisearch.com/docs/reference/api/settings/get-distinctattribute A successful request to get the distinct attribute will return a JSON string representing the attribute name. ```json "" ``` -------------------------------- ### Initialize Project Directory Source: https://www.meilisearch.com/docs/resources/migration/mongodb_migration Create a new project directory and initialize it with npm or pip/gem. Touch a script file for your migration logic. ```bash mkdir mongodb-meilisearch-migration cd mongodb-meilisearch-migration npm init -y touch script.js ``` ```bash mkdir mongodb-meilisearch-migration cd mongodb-meilisearch-migration touch script.py ``` ```bash mkdir mongodb-meilisearch-migration cd mongodb-meilisearch-migration touch script.rb ``` -------------------------------- ### Get API Keys using Meilisearch SDKs Source: https://www.meilisearch.com/docs/reference/api/authorization Examples of how to retrieve API keys using the Meilisearch SDKs in various programming languages. These snippets demonstrate initializing the client with your Meilisearch URL and master API key, then calling the method to get the keys. ```javascript const client = new MeiliSearch({ host: 'MEILISEARCH_URL', apiKey: 'masterKey' }) client.getKeys() ``` ```python client = Client('MEILISEARCH_URL', 'masterKey') client.get_keys() ``` ```php $client = new Client('MEILISEARCH_URL', 'masterKey'); $client->getKeys(); ``` ```java Client client = new Client(new Config("MEILISEARCH_URL", "masterKey")); client.getKeys(); ``` ```ruby client = MeiliSearch::Client.new('MEILISEARCH_URL', 'masterKey') client.keys ``` ```go client := meilisearch.New("MEILISEARCH_URL", meilisearch.WithAPIKey("masterKey")) client.GetKeys(nil); ``` ```csharp MeilisearchClient client = new MeilisearchClient("MEILISEARCH_URL", "masterKey"); var keys = await client.GetKeysAsync(); ``` ```rust let client = Client::new("MEILISEARCH_URL", Some("MASTER_KEY")); let keys = client .get_keys() .await .unwrap(); ``` ```swift client = try MeiliSearch(host: "MEILISEARCH_URL", apiKey: "masterKey") client.getKeys { result in switch result { case .success(let keys): print(keys) case .failure(let error): print(error) } } ``` ```dart var client = MeiliSearchClient('MEILISEARCH_URL', 'masterKey'); await client.getKeys(); ``` -------------------------------- ### Full Dart Example Source: https://www.meilisearch.com/docs/getting_started/sdks/dart A complete Dart example demonstrating connection, adding documents, waiting for tasks, and searching. ```dart import 'package:meilisearch/meilisearch.dart'; import 'dart:io'; void main() async { // Connect final client = MeiliSearchClient( Platform.environment['MEILISEARCH_URL']!, Platform.environment['MEILISEARCH_KEY'], ); // Add documents final movies = [ {'id': 1, 'title': 'The Matrix', 'year': 1999}, {'id': 2, 'title': 'Inception', 'year': 2010}, {'id': 3, 'title': 'Interstellar', 'year': 2014}, ]; final index = client.index('movies'); final task = await index.addDocuments(movies); await client.waitForTask(task.taskUid); // Search final result = await index.search('inter'); for (final hit in result.hits) { print(hit['title']); } } ``` -------------------------------- ### Checkout Specific Meilisearch Version Source: https://www.meilisearch.com/docs/resources/migration/previous_docs_version Use 'git checkout' with a version tag to retrieve the documentation for a specific Meilisearch release. For example, to get v0.20 documentation. ```bash git checkout v0.20 ``` -------------------------------- ### Example Remote Instance Configuration Source: https://www.meilisearch.com/docs/reference/api/experimental-features/configure-network-topology This example shows the structure for configuring a remote instance within the network topology. ```json {\ "ms-00": { "url": "http://localhost:7700" },\ "ms-01": { "url": "http://localhost:7701" }\ } ``` -------------------------------- ### Get API Keys Source: https://www.meilisearch.com/docs/reference/api/authorization This endpoint retrieves all existing API keys. It can only be accessed using the master key. The example demonstrates how to call this endpoint using cURL and various SDKs. ```APIDOC ## GET /keys ### Description Retrieves all existing API keys. This route can only be accessed using the master key. ### Method GET ### Endpoint /keys ### Parameters #### Query Parameters None #### Request Body None ### Request Example ```bash curl \ -X GET 'MEILISEARCH_URL/keys' \ -H 'Authorization: Bearer MASTER_KEY' ``` ### Response #### Success Response (200) - **results** (array) - An array of API key objects. - **total** (integer) - The total number of API keys. #### Response Example ```json { "results": [ { "key": "MASTER_KEY", "description": "Master API key", "permissions": [ "*,*" ], "expiresAt": null } ], "total": 1 } ``` ``` -------------------------------- ### Get All Index Stats Response (JSON) Source: https://www.meilisearch.com/docs/reference/api/stats/get-stats-of-all-indexes Example JSON response when successfully retrieving Meilisearch instance statistics. It details database size, usage, last update time, and statistics per index. ```json { "databaseSize": 567, "usedDatabaseSize": 456, "lastUpdate": "2019-11-20T09:40:33.711324Z", "indexes": { "movies": { "numberOfDocuments": 10, "rawDocumentDbSize": 100, "maxDocumentSize": 16, "avgDocumentSize": 10, "isIndexing": true, "fieldDistribution": { "genre": 10, "author": 9 } } } } ``` -------------------------------- ### Example Remote Instance Configuration Source: https://www.meilisearch.com/docs/reference/api/experimental-features/get-network-topology This example demonstrates the structure for configuring a remote instance within the network topology. It includes the URL for the remote instance. ```json { "ms-00": { "url": "http://localhost:7700" }, "ms-01": { "url": "http://localhost:7701" } } ``` -------------------------------- ### Get First Ten Films with Limit and Offset Source: https://www.meilisearch.com/docs/capabilities/full_text_search/how_to/paginate_search_results Use the `limit` and `offset` search parameters in the JavaScript SDK to retrieve a specific range of search results. This example fetches the first ten films. ```javascript const results = await index.search("tarkovsky", { limit: 10, offset: 0 }); ``` -------------------------------- ### Full Example: Add Documents and Search Source: https://www.meilisearch.com/docs/getting_started/sdks/ruby A comprehensive example demonstrating how to connect, add documents, and perform a search using the Meilisearch Ruby SDK. ```ruby require 'meilisearch' client = MeiliSearch::Client.new( ENV['MEILISEARCH_URL'], ENV['MEILISEARCH_KEY'] ) # Add documents movies = [ { id: 1, title: 'The Matrix', genres: ['Action', 'Sci-Fi'], year: 1999 }, { id: 2, title: 'Inception', genres: ['Action', 'Thriller'], year: 2010 }, { id: 3, title: 'Interstellar', genres: ['Drama', 'Sci-Fi'], year: 2014 } ] task = client.index('movies').add_documents(movies) client.wait_for_task(task['taskUid']) # Search results = client.index('movies').search('inter') puts results['hits'] ``` -------------------------------- ### Get Third Page of Search Results Source: https://www.meilisearch.com/docs/capabilities/full_text_search/how_to/paginate_search_results Retrieve a subsequent page of search results by adjusting the `offset` parameter based on the `limit`. This example fetches results for the third page, skipping the first 40 documents. ```javascript const results = await index.search("tarkovsky", { limit: 20, offset: 40 }); ``` -------------------------------- ### Example Shard Configuration Source: https://www.meilisearch.com/docs/reference/api/experimental-features/get-network-topology This example shows how to configure shards within the network topology. It maps shard names to a list of remote instances they should utilize. ```json { "shard-00": { "remotes": ["ms-00", "ms-01"] } } ``` -------------------------------- ### Create an API Key with Document Management Permissions Source: https://www.meilisearch.com/docs/capabilities/security/how_to/manage_api_keys This example demonstrates creating an API key with permissions to add, get, and delete documents for specific indexes. Setting 'expiresAt' to null creates a key that never expires. ```bash curl \ -X POST 'MEILISEARCH_URL/keys' \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer MEILISEARCH_KEY' \ --data-binary '{ "description": "Documents admin for products and reviews", "actions": ["documents.add", "documents.get", "documents.delete"], "indexes": ["products", "reviews"], "expiresAt": null }' ``` -------------------------------- ### Example Shard Configuration Source: https://www.meilisearch.com/docs/reference/api/experimental-features/configure-network-topology This example demonstrates how to configure shards and assign them to specific remotes within the network topology. ```json {\ "shard-00": { "remotes": ["ms-00", "ms-01"] }\ } ``` -------------------------------- ### Send Documents to Index via Python Source: https://www.meilisearch.com/docs/capabilities/indexing/getting_started Add documents to a Meilisearch index using the Python SDK. Install the SDK using pip. This example demonstrates loading data from a JSON file and sending it to the specified index. ```python # In the command line: # pip3 install meilisearch # In your .py file: import meilisearch import json client = meilisearch.Client('MEILISEARCH_URL', 'aSampleMasterKey') json_file = open('movies.json', encoding='utf-8') movies = json.load(json_file) client.index('movies').add_documents(movies) ``` -------------------------------- ### Launch Meilisearch with Command-Line Options Source: https://www.meilisearch.com/docs/resources/self_hosting/configuration/overview Start Meilisearch with specific database path and HTTP address using command-line arguments. ```bash ./meilisearch --db-path ./meilifiles --http-addr 'localhost:7700' ``` -------------------------------- ### Get Health Source: https://www.meilisearch.com/docs/reference/api/management/get-health The engine will return `available` status with a `200` status code when the instance is healthy. It will return `mustRestart` status with a `500` status code if the instance requires a restart. This restart is required after a compaction of the task queue for example. ```APIDOC ## GET /health ### Description Check the health status of your Meilisearch instance. ### Method GET ### Endpoint /health ### Response #### Success Response (200) - **status** (enum) - The status of the instance. Available options: `available`, `mustRestart` #### Response Example ```json { "status": "available" } ``` ``` -------------------------------- ### Install Dependencies Source: https://www.meilisearch.com/docs/resources/migration/qdrant_migration Install the required client libraries for Qdrant and Meilisearch using their respective package managers. Ensure you have the correct libraries for your chosen language. ```bash npm install -s @qdrant/js-client-rest meilisearch ``` ```bash pip install qdrant-client meilisearch ``` ```bash gem install qdrant-ruby meilisearch ``` -------------------------------- ### Get Prometheus Metrics Source: https://www.meilisearch.com/docs/reference/api/stats/get-prometheus-metrics This endpoint allows you to retrieve all available Prometheus metrics for your Meilisearch instance. These metrics provide insights into various aspects of your Meilisearch setup, including index counts, document counts, indexing status, task queues, and database size. ```APIDOC ## GET /metrics ### Description Retrieves all Prometheus metrics for the Meilisearch instance. ### Method GET ### Endpoint /metrics ### Parameters #### Query Parameters None #### Request Body None ### Response #### Success Response (200) - **Content-Type**: text/plain - **Body**: A string containing Prometheus-formatted metrics. ### Response Example ``` # HELP meilisearch_index_count Meilisearch Index Count # TYPE meilisearch_index_count gauge meilisearch_index_count 1 # HELP meilisearch_index_docs_count Meilisearch Index Docs Count # TYPE meilisearch_index_docs_count gauge meilisearch_index_docs_count{index="mieli"} 2 # HELP meilisearch_is_indexing Meilisearch Is Indexing # TYPE meilisearch_is_indexing gauge meilisearch_is_indexing 0 # HELP meilisearch_last_update Meilisearch Last Update # TYPE meilisearch_last_update gauge meilisearch_last_update 1726675964 # HELP meilisearch_nb_tasks Meilisearch Number of tasks # TYPE meilisearch_nb_tasks gauge meilisearch_nb_tasks{kind="indexes",value="mieli"} 39 meilisearch_nb_tasks{kind="statuses",value="canceled"} 0 meilisearch_nb_tasks{kind="statuses",value="enqueued"} 0 meilisearch_nb_tasks{kind="statuses",value="failed"} 4 meilisearch_nb_tasks{kind="statuses",value="processing"} 0 meilisearch_nb_tasks{kind="statuses",value="succeeded"} 35 meilisearch_nb_tasks{kind="types",value="documentAdditionOrUpdate"} 9 meilisearch_nb_tasks{kind="types",value="documentDeletion"} 0 meilisearch_nb_tasks{kind="types",value="documentEdition"} 0 meilisearch_nb_tasks{kind="types",value="dumpCreation"} 0 meilisearch_nb_tasks{kind="types",value="indexCreation"} 0 meilisearch_nb_tasks{kind="types",value="indexDeletion"} 8 meilisearch_nb_tasks{kind="types",value="indexSwap"} 0 meilisearch_nb_tasks{kind="types",value="indexUpdate"} 0 meilisearch_nb_tasks{kind="types",value="settingsUpdate"} 22 meilisearch_nb_tasks{kind="types",value="snapshotCreation"} 0 meilisearch_nb_tasks{kind="types",value="taskCancelation"} 0 meilisearch_nb_tasks{kind="types",value="taskDeletion"} 0 # HELP meilisearch_used_db_size_bytes Meilisearch Used DB Size In Bytes # TYPE meilisearch_used_db_size_bytes gauge meilisearch_used_db_size_bytes 409600 # HELP meilisearch_last_indexed_documents_count The last number of indexed documents in a batch # TYPE meilisearch_last_indexed_documents_count gauge meilisearch_last_indexed_documents_count{batch_uid="0",index="movies"} 31944 # HELP meilisearch_last_indexed_documents_duration_ms The duration in ms of the last batch that indexed documents # TYPE meilisearch_last_indexed_documents_duration_ms gauge meilisearch_last_indexed_documents_duration_ms{batch_uid="0",index="movies"} 17904 ``` ``` -------------------------------- ### Generate Article model and database migration Source: https://www.meilisearch.com/docs/getting_started/frameworks/rails Create an example Article model and generate the necessary migration files. ```bash bin/rails generate model Article title:string body:text bin/rails db:migrate ``` -------------------------------- ### System Prompt for Documentation Assistant Source: https://www.meilisearch.com/docs/capabilities/conversational_search/advanced/reduce_hallucination This system prompt guides an AI assistant to answer questions using only provided search results, cite sources, and handle missing information gracefully. It includes rules for response length and examples for both successful answers and handling missing information. ```text You are the documentation assistant for CloudDeploy. Answer questions using ONLY the search results provided by Meilisearch. Rules: - Never use information from your training data - Cite sources for every claim: [Source: document title] - If you cannot find the answer, say "I could not find this in our documentation" and suggest contacting support@clouddeploy.com - Keep answers concise (under 150 words) unless more detail is requested Example of a good answer: User: "How do I configure auto-scaling?" Search results: "Auto-scaling can be enabled in the dashboard under Settings > Scaling. Set min and max instances." Answer: "To configure auto-scaling, go to Settings > Scaling in the CloudDeploy dashboard. There you can set the minimum and maximum number of instances. [Source: Auto-scaling configuration guide]" Example of handling missing information: User: "What are the pricing tiers?" Search results: No pricing information found. Answer: "I could not find pricing information in our documentation. Please visit our pricing page or contact support@clouddeploy.com for current pricing details." ``` -------------------------------- ### Full Meilisearch Example (Swift) Source: https://www.meilisearch.com/docs/getting_started/sdks/swift A complete example demonstrating connection, document addition, and searching within a Task. ```swift import MeiliSearch // Connect let client = try! MeiliSearch( host: ProcessInfo.processInfo.environment["MEILISEARCH_URL"]!, apiKey: ProcessInfo.processInfo.environment["MEILISEARCH_KEY"] ) struct Movie: Codable, Equatable { let id: Int let title: String let year: Int } Task { // Add documents let movies = [ Movie(id: 1, title: "The Matrix", year: 1999), Movie(id: 2, title: "Inception", year: 2010), Movie(id: 3, title: "Interstellar", year: 2014) ] let index = client.index("movies") let task = try await index.addDocuments(documents: movies) try await client.waitForTask(taskUid: task.taskUid) // Search let results: Searchable = try await index.search("inter") for hit in results.hits { print(hit.title) } } ``` -------------------------------- ### List Documents with GET Source: https://www.meilisearch.com/docs/reference/api/documents/list-documents-with-get This endpoint allows you to retrieve documents from an index. You can control the number of documents returned and the starting point using offset and limit parameters. The response includes the documents themselves, the number of items skipped, the maximum number of items returned, and the total number of items matching the query. ```APIDOC ## GET /indexes/{index_uid}/documents ### Description Retrieves a list of documents from a specified index. Supports pagination via `offset` and `limit` query parameters. ### Method GET ### Endpoint `/indexes/{index_uid}/documents` ### Query Parameters - **offset** (integer) - Required - Number of items skipped. Must be greater than or equal to 0. - **limit** (integer) - Required - Maximum number of items returned. Must be greater than or equal to 0. ### Response #### Success Response (200) - **results** (any[]) - Required - Items for the current page. - **offset** (integer) - Required - Number of items skipped. - **limit** (integer) - Required - Maximum number of items returned. - **total** (integer) - Required - Total number of items matching the query. #### Response Example ```json { "results": [ // ... document objects ... ], "offset": 0, "limit": 20, "total": 100 } ``` ``` -------------------------------- ### Install .NET SDK using CLI Source: https://www.meilisearch.com/docs/getting_started/sdks/dotnet Use the .NET CLI to add the MeiliSearch package to your project. ```bash dotnet add package MeiliSearch ``` -------------------------------- ### Install Latest Meilisearch (Local Installation) Source: https://www.meilisearch.com/docs/resources/migration/updating Install the latest version of Meilisearch locally using a curl script. ```bash curl -L https://install.meilisearch.com | sh ```