{"id":13721391,"url":"https://github.com/meilisearch/meilisearch-dotnet","last_synced_at":"2025-05-07T13:32:37.886Z","repository":{"id":37737565,"uuid":"266504469","full_name":"meilisearch/meilisearch-dotnet","owner":"meilisearch","description":".NET wrapper for the Meilisearch API","archived":false,"fork":false,"pushed_at":"2024-11-13T12:23:05.000Z","size":4816,"stargazers_count":269,"open_issues_count":37,"forks_count":57,"subscribers_count":13,"default_branch":"main","last_synced_at":"2024-11-13T13:28:59.591Z","etag":null,"topics":["client","meilisearch","sdk"],"latest_commit_sha":null,"homepage":"https://meilisearch.com","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/meilisearch.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-24T08:59:06.000Z","updated_at":"2024-11-13T12:23:09.000Z","dependencies_parsed_at":"2023-12-15T19:38:49.066Z","dependency_job_id":"fbccd540-a56a-4db1-b08b-164b756d663e","html_url":"https://github.com/meilisearch/meilisearch-dotnet","commit_stats":null,"previous_names":[],"tags_count":39,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meilisearch%2Fmeilisearch-dotnet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meilisearch%2Fmeilisearch-dotnet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meilisearch%2Fmeilisearch-dotnet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/meilisearch%2Fmeilisearch-dotnet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/meilisearch","download_url":"https://codeload.github.com/meilisearch/meilisearch-dotnet/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224604918,"owners_count":17339229,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["client","meilisearch","sdk"],"created_at":"2024-08-03T01:01:16.508Z","updated_at":"2025-05-07T13:32:37.879Z","avatar_url":"https://github.com/meilisearch.png","language":"C#","funding_links":[],"categories":["Integrations"],"sub_categories":["Official Integrations"],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/meilisearch/integration-guides/main/assets/logos/meilisearch_dotnet.svg\" alt=\"Meilisearch-Dotnet\" width=\"200\" height=\"200\" /\u003e\n\u003c/p\u003e\n\n\u003ch1 align=\"center\"\u003eMeilisearch .NET\u003c/h1\u003e\n\n\u003ch4 align=\"center\"\u003e\n  \u003ca href=\"https://github.com/meilisearch/meilisearch\"\u003eMeilisearch\u003c/a\u003e |\n\u003ca href=\"https://www.meilisearch.com/cloud?utm_campaign=oss\u0026utm_source=github\u0026utm_medium=meilisearch-dotnet\"\u003eMeilisearch Cloud\u003c/a\u003e |\n  \u003ca href=\"https://www.meilisearch.com/docs\"\u003eDocumentation\u003c/a\u003e |\n  \u003ca href=\"https://discord.meilisearch.com\"\u003eDiscord\u003c/a\u003e |\n  \u003ca href=\"https://roadmap.meilisearch.com/tabs/1-under-consideration\"\u003eRoadmap\u003c/a\u003e |\n  \u003ca href=\"https://www.meilisearch.com\"\u003eWebsite\u003c/a\u003e |\n  \u003ca href=\"https://www.meilisearch.com/docs/faq\"\u003eFAQ\u003c/a\u003e\n\u003c/h4\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.nuget.org/packages/meilisearch\"\u003e\u003cimg src=\"https://img.shields.io/nuget/v/meilisearch\" alt=\"NuGet\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/meilisearch/meilisearch-dotnet/actions\"\u003e\u003cimg src=\"https://github.com/meilisearch/meilisearch-dotnet/workflows/Tests/badge.svg?branch=main\" alt=\"GitHub Workflow Status\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/meilisearch/meilisearch-dotnet/blob/main/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/badge/license-MIT-informational\" alt=\"License\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://ms-bors.herokuapp.com/repositories/63\"\u003e\u003cimg src=\"https://bors.tech/images/badge_small.svg\" alt=\"Bors enabled\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e⚡ The Meilisearch API client written for .NET\u003c/p\u003e\n\n**Meilisearch .NET** is the Meilisearch API client for C# developers.\n\n**Meilisearch** is an open-source search engine. [Learn more about Meilisearch.](https://github.com/meilisearch/meilisearch)\n\n## Table of Contents \u003c!-- omit in TOC --\u003e\n\n- [📖 Documentation](#-documentation)\n- [🔧 Installation](#-installation)\n- [🚀 Getting started](#-getting-started)\n- [🤖 Compatibility with Meilisearch](#-compatibility-with-meilisearch)\n- [🎬 Examples](#-examples)\n  - [Indexes](#indexes)\n  - [Documents](#documents)\n  - [Get Task information](#get-task-information)\n  - [Search](#search)\n- [🧰 Use a Custom HTTP Client](#-use-a-custom-http-client)\n- [⚙️ Contributing](#️-contributing)\n\n## 📖 Documentation\n\nThis readme contains all the documentation you need to start using this Meilisearch SDK.\n\nFor general information on how to use Meilisearch—such as our API reference, tutorials, guides, and in-depth articles—refer to our [main documentation website](https://www.meilisearch.com/docs/).\n\n\n## 🔧 Installation\n\nThis package targets .NET Standard 2.1.\n\nUsing the [.NET Core command-line interface (CLI) tools](https://docs.microsoft.com/en-us/dotnet/core/tools/):\n\n```bash\ndotnet add package MeiliSearch\n```\n\nor with the [Package Manager Console](https://docs.microsoft.com/en-us/nuget/tools/package-manager-console):\n\n```bash\nInstall-Package MeiliSearch\n```\n\n### Run Meilisearch \u003c!-- omit in toc --\u003e\n\n⚡️ **Launch, scale, and streamline in minutes with Meilisearch Cloud**—no maintenance, no commitment, cancel anytime. [Try it free now](https://cloud.meilisearch.com/login?utm_campaign=oss\u0026utm_source=github\u0026utm_medium=meilisearch-dotnet).\n\n🪨  Prefer to self-host? [Download and deploy](https://www.meilisearch.com/docs/learn/self_hosted/getting_started_with_self_hosted_meilisearch?utm_campaign=oss\u0026utm_source=github\u0026utm_medium=meilisearch-dotnet) our fast, open-source search engine on your own infrastructure.\n\n## 🚀 Getting started\n\n#### Add Documents \u003c!-- omit in toc --\u003e\n\n```c#\nusing System;\nusing System.Threading.Tasks;\nusing Meilisearch;\n\nnamespace GettingStarted\n{\n    class Program\n    {\n        public class Movie\n        {\n            public string Id { get; set; }\n            public string Title { get; set; }\n            public IEnumerable\u003cstring\u003e Genres { get; set; }\n        }\n\n        static async Task Main(string[] args)\n        {\n            MeilisearchClient client = new MeilisearchClient(\"http://localhost:7700\", \"masterKey\");\n\n            // An index is where the documents are stored.\n            var index = client.Index(\"movies\");\n            var documents = new Movie[] {\n                new Movie { Id = \"1\", Title = \"Carol\", Genres = new string[] { \"Romance\", \"Drama\" }  },\n                new Movie { Id = \"2\", Title = \"Wonder Woman\", Genres = new string[] { \"Action\", \"Adventure\" } },\n                new Movie { Id = \"3\", Title = \"Life of Pi\", Genres = new string[] { \"Adventure\", \"Drama\" } },\n                new Movie { Id = \"4\", Title = \"Mad Max: Fury Road\", Genres = new string[] { \"Adventure\", \"Science Fiction\"} },\n                new Movie { Id = \"5\", Title = \"Moana\", Genres = new string[] { \"Fantasy\", \"Action\" } },\n                new Movie { Id = \"6\", Title = \"Philadelphia\", Genres = new string[] { \"Drama\" } }\n            };\n\n            // If the index 'movies' does not exist, Meilisearch creates it when you first add the documents.\n            var task = await index.AddDocumentsAsync\u003cMovie\u003e(documents); // # =\u003e { \"uid\": 0 }\n        }\n    }\n}\n```\n\nWith the `uid`, you can check the status (`enqueued`, `canceled`, `processing`, `succeeded` or `failed`) of your documents addition using the [task](https://www.meilisearch.com/docs/reference/api/tasks).\n\n#### Basic Search \u003c!-- omit in toc --\u003e\n\n```c#\n//Meilisearch is typo-tolerant:\nSearchResult\u003cMovie\u003e movies = await index.SearchAsync\u003cMovie\u003e(\"philadalphia\");\nforeach(var prop in movies.Hits) {\n    Console.WriteLine (prop.Title);\n}\n```\n\nJSON Output:\n\n```json\n{\n    \"hits\": [\n        {\n            \"id\": 6,\n            \"title\": \"Philadelphia\",\n        }\n    ],\n    \"offset\": 0,\n    \"limit\": 20,\n    \"processingTimeMs\": 10,\n    \"query\": \"philadalphia\"\n}\n```\n\n#### Custom Search \u003c!-- omit in toc --\u003e\n\nAll the supported options are described in the [search parameters](https://www.meilisearch.com/docs/reference/api/search#search-parameters) section of the documentation.\n\n```c#\nvar movies = await index.SearchAsync\u003cMovie\u003e(\n    \"car\",\n    new SearchQuery\n    {\n        AttributesToHighlight = new string[] { \"title\" },\n    }\n);\n\nforeach(var prop in movies.Hits) {\n    Console.WriteLine (prop.Title);\n}\n```\n\nJSON Output:\n\n```json\n{\n    \"hits\": [\n        {\n            \"id\": 1,\n            \"title\": \"Carol\",\n            \"_formatted\": {\n                \"id\": 1,\n                \"title\": \"\u003cem\u003eCar\u003c/em\u003eol\"\n            }\n        }\n    ],\n    \"offset\": 0,\n    \"limit\": 20,\n    \"processingTimeMs\": 10,\n    \"query\": \"car\"\n}\n```\n\n#### Custom Search With Filters \u003c!-- omit in toc --\u003e\n\nIf you want to enable filtering, you must add your attributes to the `FilterableAttributes` index setting.\n\n```c#\nTaskInfo task = await index.UpdateFilterableAttributesAsync(\n    new string[] { \"id\", \"genres\" }\n);\n```\n\nYou only need to perform this operation once.\n\nNote that MeiliSearch will rebuild your index whenever you update `FilterableAttributes`. Depending on the size of your dataset, this might take time. You can track the process using the [update status](https://www.meilisearch.com/docs/reference/api/tasks#status).\n\nThen, you can perform the search:\n\n```c#\nvar movies = await index.SearchAsync\u003cMovie\u003e(\n    \"wonder\",\n    new SearchQuery\n    {\n        Filter = \"id \u003e 1 AND genres = Action\",\n    }\n);\n```\n\nJSON Output:\n\n```json\n{\n  \"hits\": [\n    {\n      \"id\": 2,\n      \"title\": \"Wonder Woman\",\n      \"genres\": [\"Action\",\"Adventure\"]\n    }\n  ],\n  \"offset\": 0,\n  \"limit\": 20,\n  \"estimatedTotalHits\": 1,\n  \"processingTimeMs\": 0,\n  \"query\": \"wonder\"\n}\n```\n\n#### Search with Limit and Offset\n\nYou can paginate search results by making queries combining both [offset](https://www.meilisearch.com/docs/reference/api/search#offset) and [limit](https://www.meilisearch.com/docs/reference/api/search#limit).\n\n```c#\nvar results = await index.SearchAsync\u003cT\u003e(query, new SearchQuery()\n{\n    Limit = 5,\n    Offset = 0\n});\n\nif (results is SearchResult\u003cT\u003e limitedResults)\n{\n    var estimatedTotalHits = limitedResults.EstimatedTotalHits;\n}\n```\n\n#### Search with defined number of results per page\n\nTo get paginated results with page numbers, the [HitsPerPage](https://www.meilisearch.com/docs/reference/api/search#number-of-results-per-page) and [Page](https://www.meilisearch.com/docs/reference/api/search#page) properties must be defined.\n\n```c#\nvar results = await index.SearchAsync\u003cT\u003e(query, new SearchQuery()\n{\n    HitsPerPage = pageSize,\n    Page = pageNumber,\n});\n\nif (results is PaginatedSearchResult\u003cT\u003e paginatedResults)\n{\n    var totalHits = paginatedResults.TotalHits;\n    var totalPages = paginatedResults.TotalPages;\n}\n```\n\n## 🤖 Compatibility with Meilisearch\n\nThis package guarantees compatibility with [version v1.x of Meilisearch](https://github.com/meilisearch/meilisearch/releases/latest), but some features may not be present. Please check the [issues](https://github.com/meilisearch/meilisearch-dotnet/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22+label%3Aenhancement) for more info.\n\n## 🎬 Examples\n\n### Indexes\n\n#### Create an index \u003c!-- omit in toc --\u003e\n\n```c#\nvar index = await client.CreateIndexAsync(\"movies\");\n```\n\n#### Create an index and give the primary-key \u003c!-- omit in toc --\u003e\n\n```c#\nvar index = await client.CreateIndexAsync(\"movies\", \"id\");\n```\n\n#### List all an index \u003c!-- omit in toc --\u003e\n\n```c#\nvar indexes = await client.GetAllIndexesAsync();\n```\n\n#### Get an Index object \u003c!-- omit in toc --\u003e\n\n```c#\nvar index = await client.GetIndexAsync(\"movies\");\n```\n\n### Documents\n\n#### Add or Update Documents \u003c!-- omit in toc --\u003e\n\n```c#\nvar task = await index.AddDocumentsAsync(new Movie[] { new Movie { Id = \"1\", Title = \"Carol\" } } );\nvar task = await index.UpdateDocumentsAsync(new Movie[] { new Movie { Id = \"1\", Title = \"Carol\" } } );\n```\n\nThe returned `task` is a `TaskInfo` that can access to `Uid` to get the status of the task.\n\n#### Get Documents \u003c!-- omit in toc --\u003e\n\n```c#\nvar documents = await index.GetDocumentsAsync\u003cMovie\u003e(new DocumentsQuery { Limit = 1 });\n```\n\n#### Get Document by Id \u003c!-- omit in toc --\u003e\n\n```c#\nvar document = await index.GetDocumentAsync\u003cMovie\u003e(\"10\");\n```\n\n#### Delete documents \u003c!-- omit in toc --\u003e\n\n```c#\nvar task = await index.DeleteOneDocumentAsync(\"11\");\n```\n\n#### Delete in Batch \u003c!-- omit in toc --\u003e\n\n```c#\nvar task = await index.DeleteDocumentsAsync(new [] {\"12\",\"13\",\"14\"});\n```\n\n#### Delete all documents \u003c!-- omit in toc --\u003e\n\n```c#\nvar task = await indextoDelete.DeleteAllDocumentsAsync();\n```\n\n### Get Task information\n\n#### Get one Task By Uid \u003c!-- omit in toc --\u003e\n\n```c#\nTaskInfo task = await index.GetTaskAsync(1);\n// Or\nTaskInfo task = await client.GetTaskAsync(1);\n```\n\n#### Get All Tasks \u003c!-- omit in toc --\u003e\n\n```c#\nvar task = await index.GetTasksAsync();\n// Or\nvar task = await client.GetTasksAsync();\n```\n\n### Search\n\n#### Basic Search \u003c!-- omit in toc --\u003e\n\n```c#\nvar movies = await this.index.SearchAsync\u003cMovie\u003e(\"prince\");\n```\n\n#### Custom Search \u003c!-- omit in toc --\u003e\n\n```c#\nvar movies = await this.index.SearchAsync\u003cMovie\u003e(\"prince\", new SearchQuery { Limit = 100 });\n```\n\n## 🧰 Use a Custom HTTP Client\n\nYou can replace the default client used in this package by the one you want.\n\nFor example:\n\n```c#\nvar _httpClient = ClientFactory.Instance.CreateClient\u003cMeilisearchClient\u003e();\nvar client = new MeilisearchClient(_httpClient);\n```\n\nWhere `ClientFactory` is declared [like this](/tests/Meilisearch.Tests/ClientFactory.cs).\n\n## ⚙️ Contributing\n\nAny new contribution is more than welcome in this project!\n\nIf you want to know more about the development workflow or want to contribute, please visit our [contributing guidelines](/CONTRIBUTING.md) for detailed instructions!\n\n\u003chr\u003e\n\n**Meilisearch** provides and maintains many **SDKs and Integration tools** like this one. We want to provide everyone with an **amazing search experience for any kind of project**. If you want to contribute, make suggestions, or just know what's going on right now, visit us in the [integration-guides](https://github.com/meilisearch/integration-guides) repository.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeilisearch%2Fmeilisearch-dotnet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmeilisearch%2Fmeilisearch-dotnet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmeilisearch%2Fmeilisearch-dotnet/lists"}