YMJake.ManticoreSearch.Client 1.2.1

dotnet add package YMJake.ManticoreSearch.Client --version 1.2.1
                    
NuGet\Install-Package YMJake.ManticoreSearch.Client -Version 1.2.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="YMJake.ManticoreSearch.Client" Version="1.2.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="YMJake.ManticoreSearch.Client" Version="1.2.1" />
                    
Directory.Packages.props
<PackageReference Include="YMJake.ManticoreSearch.Client" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add YMJake.ManticoreSearch.Client --version 1.2.1
                    
#r "nuget: YMJake.ManticoreSearch.Client, 1.2.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package YMJake.ManticoreSearch.Client@1.2.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=YMJake.ManticoreSearch.Client&version=1.2.1
                    
Install as a Cake Addin
#tool nuget:?package=YMJake.ManticoreSearch.Client&version=1.2.1
                    
Install as a Cake Tool

ManticoreSearch .NET Client

Handcrafted C# SDK mirroring the official PHP client. Every endpoint, table helper, query builder, result wrapper, and admin API is handwritten.

Features

  • Table CRUD, bulk, DDL, PQ search/management, cluster/nodes utilities.
  • Fluent typed DSL (SearchRequestDescriptor<T>) + low-level SQL/CLI escape hatch.
  • Result wrappers (ResultSet) with hits + metadata (took, timed_out, facets, profile).
  • Pluggable node pools and transport hooks (ILogger, IHttpTransportFactory).
  • Serializer customization with System.Text.Json context support.
  • Schema mapping via TableSchemaBuilder + [ManticoreField].
  • KNN naming aligned to Manticore (query_vector, doc_id, query).

Quick Start

var pool = new SingleManticoreNodePool(new Uri("http://127.0.0.1:9308"));
var client = new ManticoreClient(new ManticoreClientSettings(pool));
var table = client.Table("movies");

var schema = TableSchemaBuilder.FromType<Movie>(descriptor => descriptor
    .Column(m => m.Title, "text", opts => opts.Indexed().Stored())
    .Column("created_at", "timestamp"));

await table.CreateAsync(schema, silent: true);
await table.AddDocumentAsync(new { title = "Interstellar", rating = 8.5 }, id: 1);

var typed = await table.SearchAsync<Movie>(s => s
    .Match(m => m.Title, "Interstellar")
    .Range(x => x.Rating, gte: 8)
    .Limit(5));

Advanced Query Examples

await table.SearchAsync<Movie>(s => s
    .Match(m => m.Genre, "thriller")
    .Join(new JoinClause(
        type: "inner",
        table: "directors",
        leftField: "director_id",
        rightField: "id",
        leftFieldType: "int",
        query: new QueryStringQueryClause("country:US")))
    .ScriptFields(sf => sf.Add("score", "doc['rating'] * params.boost"))
    .Knn(k => k
        .Field("embedding")
        .K(5)
        .DocumentId(42)));

Multilingual SQL Sample

Inspired by liweinan/manticoresearch-example, the sample uses SQL + MATCH() + tokenization flow.

var table = client.Table("documents_idx_sample");
await table.DropAsync(silent: true);

var schema = TableSchemaBuilder.FromType<SampleDocument>(d => d
    .Column(x => x.Title, "text", opts => opts.Indexed().Stored())
    .Column(x => x.Content, "text", opts => opts.Indexed().Stored())
    .Column(x => x.Tags, "text", opts => opts.Indexed().Stored()));

await client.Tables().CreateAsync(
    "documents_idx_sample",
    schema,
    new Dictionary<string, object>
    {
        ["min_word_len"] = "1",
        ["min_infix_len"] = "1",
        ["expand_keywords"] = "1",
        ["morphology"] = "none",
        ["index_exact_words"] = "1",
        ["ngram_len"] = "2",
        ["ngram_chars"] = "cjk"
    },
    silent: true);

var matchExpression = "\"测试\" \"test\"";
var sql = $"SELECT id, title, content, WEIGHT() AS weight FROM `documents_idx_sample` WHERE MATCH('{matchExpression}') ORDER BY weight DESC LIMIT 10";
var response = await client.SqlAsync(sql, rawResponse: false);

Run standalone sample:

dotnet run --project ManticoreSearch.Sample

Transport & Authentication

var uris = new[]
{
    new Uri("https://node1.example.com:9308"),
    new Uri("https://node2.example.com:9308"),
    new Uri("https://node3.example.com:9308")
};

var pool = new StaticManticoreNodePool(uris);

var settings = new ManticoreClientSettings(
        pool,
        sourceSerializerFactory: _ => new DefaultManticoreSourceSerializer(MySourceContext.Default))
    .Authentication(new BasicAuthentication("elastic", "changeme"))
    .Proxy("http://proxy.internal:8080");

var client = new ManticoreClient(settings);

MySourceContext is your generated JsonSerializerContext.

Note: Manticore server itself does not enforce built-in HTTP Basic auth by default. Use .Authentication(...) when your deployment has an auth gateway/reverse proxy (Nginx/API gateway) that validates Authorization headers before forwarding to Manticore.

Error Handling

The low-level transport maps failures into explicit exception types:

  • ManticoreConnectionException: network/connectivity failures.
  • ManticoreTimeoutException: request timeout.
  • ManticoreServerException: non-success HTTP status (includes StatusCode and ResponseBody).
  • ManticoreSerializationException: response deserialization failure.

ManticoreClient/LowLevel stays low-level; TableClient/Search are thin wrappers over the same transport.

Release Notes

[1.2.0] - 2026-02-26

Changed:

  • Refactored SQL internals into focused components: SqlText, SqlBuilder, and DocumentPayload.
  • Unified SQL statement composition style across TableClient, ClusterClient, TablesAdminClient, and NodesClient.
  • Aligned KNN payload naming with current Manticore conventions: query_vector, doc_id, and query.
  • Updated README examples to match current multilingual SQL sample behavior.

Added:

  • xUnit-based regression tests for KNN serialization, search response shaping, SQL builder formatting, and document payload normalization.
  • InternalsVisibleTo setup for internal-component unit testing.

Notes:

  • BasicAuthentication in client settings is intended for proxy/gateway authentication in front of Manticore.

[1.1.0] - 2026-02-26

Added:

  • Initial public package release for .NET 8 / .NET 10 targets.
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.1 87 2/26/2026
1.2.0 82 2/26/2026
1.1.0 118 11/29/2025
1.0.0 179 11/26/2025

Added layered transport exceptions (connection/timeout/server/serialization), refined retry classification, and documented low-level vs thin-wrapper boundaries in README.