ManticoreSearch.Provider 1.1.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package ManticoreSearch.Provider --version 1.1.1                
NuGet\Install-Package ManticoreSearch.Provider -Version 1.1.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="ManticoreSearch.Provider" Version="1.1.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ManticoreSearch.Provider --version 1.1.1                
#r "nuget: ManticoreSearch.Provider, 1.1.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.
// Install ManticoreSearch.Provider as a Cake Addin
#addin nuget:?package=ManticoreSearch.Provider&version=1.1.1

// Install ManticoreSearch.Provider as a Cake Tool
#tool nuget:?package=ManticoreSearch.Provider&version=1.1.1                

ManticoreProvider

Manticore Search – easy-to-use open-source fast database for search

Initial release of ManticoreSearch.Provider providing API integration with ManticoreSearch for .NET applications. This version includes features for full-text search, autocomplete, fuzzy search, basic CRUD operations, support for custom queries and filters, and flexible indexing and query expansion options. Designed to simplify ManticoreSearch integration in .NET projects.

Note: If you find errors or bugs in the library, please write to the email anton.panin75@gmail.com

Usage

Creating an Instance

Create an instance of ManticoreProvider, specifying the base address of Manticore Search. If the address is not specified, http://localhost:9308 will be used by default.

var provider = new ManticoreProvider(); // defaults to http://localhost:9308
// or
var provider = new ManticoreProvider("http://your-manticore-address");

Executing SQL Queries

To execute an SQL query, use the Sql method or its asynchronous variant SqlAsync:

string result = provider.Sql("SELECT * FROM your_index");
// or
string resultAsync = await provider.SqlAsync("SELECT * FROM your_index");

Inserting Documents

To insert documents into the index, use the Insert method or InsertAsync:

var request = new ModificationRequest
    {
        Index = "products",
        Document = new Dictionary<string, object>
        {
            { "title", "jopa" },
            { "price", 19.0f },
            { "count", 3 }
        }
    }
};

var insertResponse = provider.Insert(request);
// or
var insertResponseAsync = await provider.InsertAsync(request);

Bulking Documents

To perform bulk upload of documents use Bulk method or BulkAsync:

for (int i = 0; i < 20; i++)
{
    request.Add(new()
    {
        Insert = new ModificationRequest
        {
            Index = "products",
            Id = i + 1,
            Document = new Dictionary<string, object>
            {
                { "title", "burger" },
                { "price", random.Next(1, 20) },
                { "count", random.Next(1, 5) }
            }
        }
    });
}

var result = provider.Bulk(request);
// or
var resultAsync = await provider.BulkAsync(request);

Replacement of Documents

To replace documents, use Replace method or ReplaceAsync:

var request = new ModificationRequest
{
    Index = "products",
    Id = 1,
    Document = new Dictionary<string, object>
    {
        { "title", "sosal" },
        { "price", 100.0f },
        { "count", 25 }
    }
};

var result = provider.Replace(request);
// or
var resultAsync = await provider.ReplaceAsync(request);

Bulk Replacement of Documents

To perform a bulk document replacement, use BulkReplace method or BulkReplaceAsync:

var request = new List<BulkReplaceRequest>()
{
    new()
    {
        Replace = new()
        {
            Index = "products",
            Id = 9,
            Document = new Dictionary<string, object>()
            {
                { "title", "goida" },
                { "price", 15 },
                { "count", 2 }
            }
        }
    },
    new()
    {
        Replace = new()
        {
            Index = "products",
            Id = 100,
            Document = new Dictionary<string, object>()
            {
                { "title", "svo" },
                { "price", 14 },
                { "count", 3 }
            }
        }
    },
};

var result = provider.BulkReplace(request);
// or
var resultAsync = await provider.BulkReplaceAsync(request);

Updating Documents

To update documents, use Update method or UpdateAsync:

var request = new UpdateRequest()
{
    Index = "products",
    Id = 1,
    Document = new Dictionary<string, object>
    {
        { "title", "tanki online" },
        { "price", 30.0f },
        { "count", 1 }
    }
};

Bulk Updating Documents

To update documents, use Update method or UpdateAsync:

var request = new List<BulkUpdateRequest>
{
    new()
    {
        Update = new()
        {
            Index = "products",
            Query = new Query
            {
                Equals = new Dictionary<string, object>
                {
                    { "title", "burger" }
                }
            },
            Document = new Dictionary<string, object>
            {
                { "title", "kit kat" }
            }
        }
    },
    new()
    {
        Update = new()
        {
            Index = "products",
            Query = new Query
            {
                Range = new Dictionary<string, QueryRange>
                {
                    { "price", new QueryRange { Lt = 10 } }
                }
            },
            Document = new Dictionary<string, object>
            {
                { "price", 10 }
            }
        }
    }
};

var result = provider.BulkUpdate(request);
// or
var resultAsync = await provider.BulkUpdateAsync(request);

Search by Documents

To search documents, use Search method or SearchAsync:

var request = new SearchRequest
{
    Index = "articles",
    Limit = 1000,
    Query = new Query
    {
        Bool = new QueryBool
        {
            Must = new List<BoolMust>
            {
                new BoolMust
                {
                    Match = new Dictionary<string, object>
                    {
                        { "body", "Putin" }
                    }
                }
            },
            MustNot = new List<BoolMust>
            {
                new BoolMust 
                {
                    Match = new Dictionary<string, object>
                    {
                        { "body", "Trump" }
                    }
                }
            }
        }
    }
};

var result = provider.Search(request);
// or
var resultAsync = await provider.SearchAsync(request);

Deleting Documents

To delete documents, use Delete method or DeleteAsync:

var request = new DeleteRequest
{
    Index = "products",
    Id = 2
};

var result = provider.Delete(request);
// or
var resultAsync = await provider.DeleteAsync(request);

Bulk Deletion of Documents

To perform bulk deletion of documents use BulkDelete method or BulkDeleteAsync:

var request = new List<BulkDeleteRequest>
{
    new()
    {
        Delete = new DeleteRequest
        {
            Index = "products",
            Query = new Query
            {
                Range = new Dictionary<string, QueryRange>
                {
                    { "id", new QueryRange { Lt = 5 } }
                }
            }
        }
    },
    new()
    {
        Delete = new DeleteRequest
        {
            Index = "products",
            Query = new Query
            {
                Range = new Dictionary<string, QueryRange>
                {
                    { "price", new QueryRange { Gt = 10 } }
                }
            }
        }
    }
};

var result = provider.BulkDelete(request);
// or
var resultAsync = await provider.BulkDeleteAsync(request);

Working with Percolators

To index and search using percolators, use the IndexPercolate, Percolate, GetPercolate and UpdatePercolate methods and their asynchronous versions:

var resuest = new IndexPercolateRequest
{
    Query = new Query
    {
        Match = new Dictionary<string, object>
        {
            { "title", "Nasral" }
        }
    }
};

var result = provider.Percolate(resuest, "your_index");
// or
var resultAsync = await provider.PercolateAsync(resuest, "your_index");

Autocomplete request

Retrieves autocomplete suggestions based on the provided autocomplete query. Use the Autocomplete or AutocompleteAsync methods:

var request = new IndexPercolateRequest
{
    Query = new Query
    {
        Match = new Dictionary<string, object>
        {
            { "title", "Pupkin" }
        }
    }
};

var result = apiInstance.IndexPercolate(request, "pqtable", 5);
// or
var resultAsync = await apiInstance.IndexPercolateAsync(request, "pqtable", 5);

Mapping request

Defines a new table structure in Manticore search engine using the specified mapping properties, mimicking Elasticsearch-like table definitions. Use the UseMapping or UseMappingAsync methods:

var request = new MappingRequest
{
    Properties = new Dictionary<string, MappingField>
    {
        { "exersice", new MappingField { Type = FieldType.Keyword } },
        { "working_weight", new MappingField { Type = FieldType.Integer } },
        { "weight_limit", new MappingField { Type = FieldType.Integer } }
    }
};

var result = apiInstance.UseMapping(request, "training");
// or
var resultAsync = await apiInstance.UseMappingAsync(request, "training");

Exceptions

  • AutocompleteException — on Autocomplete request error.
  • BulkException — on Bulk request error.
  • DeleteException — on Delete request error.
  • MappingException — on Mapping request error.
  • ModificationException — on Modification request error.
  • PercolateException — on Percolate request error.
  • SearchException — on Search request error.
  • SqlException — on SQL request error.
  • UpdateException — on Update request error.

Cleanup

Remember to release resources by calling the Dispose method when you are done using ManticoreProvider.

provider.Dispose();
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. 
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 80 11/5/2024
1.2.0 69 11/5/2024
1.1.2 80 11/5/2024
1.1.1 87 11/2/2024
1.1.0 72 11/2/2024
1.0.3 70 11/2/2024
1.0.2 72 11/2/2024
1.0.1 72 11/2/2024
1.0.0 68 11/2/2024

Initial release of ManticoreSearch.Provider providing API integration with ManticoreSearch for .NET applications. This version includes features for full-text search, autocomplete, fuzzy search, basic CRUD operations, support for custom queries and filters, and flexible indexing and query expansion options. Designed to simplify ManticoreSearch integration in .NET projects.