![]() |
VOOZH | about |
dotnet add package MeiliSearch --version 0.18.0
NuGet\Install-Package MeiliSearch -Version 0.18.0
<PackageReference Include="MeiliSearch" Version="0.18.0" />
<PackageVersion Include="MeiliSearch" Version="0.18.0" />Directory.Packages.props
<PackageReference Include="MeiliSearch" />Project file
paket add MeiliSearch --version 0.18.0
#r "nuget: MeiliSearch, 0.18.0"
#:package MeiliSearch@0.18.0
#addin nuget:?package=MeiliSearch&version=0.18.0Install as a Cake Addin
#tool nuget:?package=MeiliSearch&version=0.18.0Install as a Cake Tool
<p align="center"> <img src="https://raw.githubusercontent.com/meilisearch/integration-guides/main/assets/logos/meilisearch_dotnet.svg" alt="Meilisearch-Dotnet" width="200" height="200" /> </p>
<h1 align="center">Meilisearch .NET</h1>
<h4 align="center"> <a href="https://github.com/meilisearch/meilisearch">Meilisearch</a> | <a href="https://www.meilisearch.com/cloud?utm_campaign=oss&utm_source=github&utm_medium=meilisearch-dotnet">Meilisearch Cloud</a> | <a href="https://www.meilisearch.com/docs">Documentation</a> | <a href="https://discord.meilisearch.com">Discord</a> | <a href="https://roadmap.meilisearch.com/tabs/1-under-consideration">Roadmap</a> | <a href="https://www.meilisearch.com">Website</a> | <a href="https://www.meilisearch.com/docs/faq">FAQ</a> </h4>
<p align="center"> <a href="https://www.nuget.org/packages/meilisearch"><img src="https://img.shields.io/nuget/v/meilisearch" alt="NuGet"></a> <a href="https://github.com/meilisearch/meilisearch-dotnet/actions"><img src="https://github.com/meilisearch/meilisearch-dotnet/workflows/Tests/badge.svg?branch=main" alt="GitHub Workflow Status"></a> <a href="https://github.com/meilisearch/meilisearch-dotnet/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-informational" alt="License"></a> </p>
<p align="center">⚡ The Meilisearch API client written for .NET</p>
Meilisearch .NET is the Meilisearch API client for C# developers.
Meilisearch is an open-source search engine. Learn more about Meilisearch.
This readme contains all the documentation you need to start using this Meilisearch SDK.
For general information on how to use Meilisearch—such as our API reference, tutorials, guides, and in-depth articles—refer to our main documentation website.
This package targets .NET Standard 2.1.
Using the .NET Core command-line interface (CLI) tools:
dotnet add package MeiliSearch
or with the Package Manager Console:
Install-Package MeiliSearch
⚡️ Launch, scale, and streamline in minutes with Meilisearch Cloud—no maintenance, no commitment, cancel anytime. Try it free now.
🪨 Prefer to self-host? Download and deploy our fast, open-source search engine on your own infrastructure.
using System;
using System.Threading.Tasks;
using Meilisearch;
namespace GettingStarted
{
class Program
{
public class Movie
{
public string Id { get; set; }
public string Title { get; set; }
public IEnumerable<string> Genres { get; set; }
}
static async Task Main(string[] args)
{
MeilisearchClient client = new MeilisearchClient("http://localhost:7700", "masterKey");
// An index is where the documents are stored.
var index = client.Index("movies");
var documents = new Movie[] {
new Movie { Id = "1", Title = "Carol", Genres = new string[] { "Romance", "Drama" } },
new Movie { Id = "2", Title = "Wonder Woman", Genres = new string[] { "Action", "Adventure" } },
new Movie { Id = "3", Title = "Life of Pi", Genres = new string[] { "Adventure", "Drama" } },
new Movie { Id = "4", Title = "Mad Max: Fury Road", Genres = new string[] { "Adventure", "Science Fiction"} },
new Movie { Id = "5", Title = "Moana", Genres = new string[] { "Fantasy", "Action" } },
new Movie { Id = "6", Title = "Philadelphia", Genres = new string[] { "Drama" } }
};
// If the index 'movies' does not exist, Meilisearch creates it when you first add the documents.
var task = await index.AddDocumentsAsync<Movie>(documents); // # => { "uid": 0 }
}
}
}
With the uid, you can check the status (enqueued, canceled, processing, succeeded or failed) of your documents addition using the task.
//Meilisearch is typo-tolerant:
SearchResult<Movie> movies = await index.SearchAsync<Movie>("philadalphia");
foreach(var prop in movies.Hits) {
Console.WriteLine (prop.Title);
}
JSON Output:
{
"hits": [
{
"id": 6,
"title": "Philadelphia",
}
],
"offset": 0,
"limit": 20,
"processingTimeMs": 10,
"query": "philadalphia"
}
All the supported options are described in the search parameters section of the documentation.
var movies = await index.SearchAsync<Movie>(
"car",
new SearchQuery
{
AttributesToHighlight = new string[] { "title" },
}
);
foreach(var prop in movies.Hits) {
Console.WriteLine (prop.Title);
}
JSON Output:
{
"hits": [
{
"id": 1,
"title": "Carol",
"_formatted": {
"id": 1,
"title": "<em>Car</em>ol"
}
}
],
"offset": 0,
"limit": 20,
"processingTimeMs": 10,
"query": "car"
}
If you want to enable filtering, you must add your attributes to the FilterableAttributes index setting.
TaskInfo task = await index.UpdateFilterableAttributesAsync(
new string[] { "id", "genres" }
);
You only need to perform this operation once.
Note 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.
Then, you can perform the search:
var movies = await index.SearchAsync<Movie>(
"wonder",
new SearchQuery
{
Filter = "id > 1 AND genres = Action",
}
);
JSON Output:
{
"hits": [
{
"id": 2,
"title": "Wonder Woman",
"genres": ["Action","Adventure"]
}
],
"offset": 0,
"limit": 20,
"estimatedTotalHits": 1,
"processingTimeMs": 0,
"query": "wonder"
}
You can paginate search results by making queries combining both offset and limit.
var results = await index.SearchAsync<T>(query, new SearchQuery()
{
Limit = 5,
Offset = 0
});
if (results is SearchResult<T> limitedResults)
{
var estimatedTotalHits = limitedResults.EstimatedTotalHits;
}
To get paginated results with page numbers, the HitsPerPage and Page properties must be defined.
var results = await index.SearchAsync<T>(query, new SearchQuery()
{
HitsPerPage = pageSize,
Page = pageNumber,
});
if (results is PaginatedSearchResult<T> paginatedResults)
{
var totalHits = paginatedResults.TotalHits;
var totalPages = paginatedResults.TotalPages;
}
To get results sorted by attributes and preferred sorting order, the Sort property must be defined.
var results = await index.SearchAsync<T>(query, new SearchQuery()
{
Sort = new List<string> { "genre:asc", "name:desc" }
});
This package guarantees compatibility with version v1.x of Meilisearch, but some features may not be present. Please check the issues for more info.
var index = await client.CreateIndexAsync("movies");
var index = await client.CreateIndexAsync("movies", "id");
var indexes = await client.GetAllIndexesAsync();
var index = await client.GetIndexAsync("movies");
var task = await index.AddDocumentsAsync(new Movie[] { new Movie { Id = "1", Title = "Carol" } } );
var task = await index.UpdateDocumentsAsync(new Movie[] { new Movie { Id = "1", Title = "Carol" } } );
The returned task is a TaskInfo that can access to Uid to get the status of the task.
var documents = await index.GetDocumentsAsync<Movie>(new DocumentsQuery { Limit = 1 });
var document = await index.GetDocumentAsync<Movie>("10");
var task = await index.DeleteOneDocumentAsync("11");
var task = await index.DeleteDocumentsAsync(new [] {"12","13","14"});
var task = await indextoDelete.DeleteAllDocumentsAsync();
TaskInfo task = await index.GetTaskAsync(1);
// Or
TaskInfo task = await client.GetTaskAsync(1);
var task = await index.GetTasksAsync();
// Or
var task = await client.GetTasksAsync();
var movies = await this.index.SearchAsync<Movie>("prince");
var movies = await this.index.SearchAsync<Movie>("prince", new SearchQuery { Limit = 100 });
You can replace the default client used in this package by the one you want.
For example:
var _httpClient = ClientFactory.Instance.CreateClient<MeilisearchClient>();
var client = new MeilisearchClient(_httpClient);
Where ClientFactory is declared .
Any new contribution is more than welcome in this project!
If you want to know more about the development workflow or want to contribute, please visit our for detailed instructions!
<hr>
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 repository.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on MeiliSearch:
| Package | Downloads |
|---|---|
|
CommunityToolkit.Aspire.Meilisearch
A Meilisearch client that integrates with Aspire, including health checks, logging, and telemetry. |
|
|
CommunityToolkit.Aspire.Hosting.Meilisearch
Meilisearch support for Aspire. |
|
|
Pina.MeiliSearch
Package Description |
|
|
Vhat.Infrastructure
Viet Hung Automation Technology Common Infrastructure Libraries |
|
|
Chaosage.Core.Search.Meili
Chaosage开发平台MeiliSearch操作库 |
Showing the top 3 popular GitHub repositories that depend on MeiliSearch:
| Repository | Stars |
|---|---|
|
CommunityToolkit/Aspire
A community project with additional components and extensions for Aspire
|
|
|
arnesacnussem/jellyfin-plugin-meilisearch
A search plugin for Jellyfin
|
|
|
CnGal/CnGalWebSite
CnGal是一个非营利性的,立志于收集整理国内制作组创作的中文Galgame/AVG的介绍、攻略、评测、感想等内容的资料性质的网站。
|
| Version | Downloads | Last Updated |
|---|---|---|
| 0.18.0 | 182,457 | 12/9/2025 |
| 0.17.1 | 83,686 | 9/18/2025 |
| 0.17.0 | 27,201 | 8/11/2025 |
| 0.16.0 | 211,696 | 1/22/2025 |
| 0.15.5 | 59,028 | 11/27/2024 |
| 0.15.4 | 15,064 | 11/14/2024 |
| 0.15.3 | 92,591 | 8/6/2024 |
| 0.15.2 | 826 | 8/5/2024 |
| 0.15.1 | 7,094 | 7/10/2024 |
| 0.15.0 | 68,877 | 3/11/2024 |
| 0.14.7 | 21,746 | 1/17/2024 |
| 0.14.6 | 15,415 | 10/25/2023 |
| 0.14.5 | 1,136 | 10/12/2023 |
| 0.14.4 | 2,373 | 9/25/2023 |
| 0.14.3 | 36,109 | 7/11/2023 |
| 0.14.2 | 22,630 | 5/8/2023 |
| 0.14.1 | 20,086 | 4/3/2023 |
| 0.14.0 | 5,657 | 3/16/2023 |
| 0.13.1 | 6,333 | 2/6/2023 |
| 0.13.0 | 16,353 | 12/5/2022 |