NetCoreBackend.NArchitecture.Core.ElasticSearch
1.0.1
dotnet add package NetCoreBackend.NArchitecture.Core.ElasticSearch --version 1.0.1
NuGet\Install-Package NetCoreBackend.NArchitecture.Core.ElasticSearch -Version 1.0.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="NetCoreBackend.NArchitecture.Core.ElasticSearch" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NetCoreBackend.NArchitecture.Core.ElasticSearch" Version="1.0.1" />
<PackageReference Include="NetCoreBackend.NArchitecture.Core.ElasticSearch" />
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 NetCoreBackend.NArchitecture.Core.ElasticSearch --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: NetCoreBackend.NArchitecture.Core.ElasticSearch, 1.0.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 NetCoreBackend.NArchitecture.Core.ElasticSearch@1.0.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=NetCoreBackend.NArchitecture.Core.ElasticSearch&version=1.0.1
#tool nuget:?package=NetCoreBackend.NArchitecture.Core.ElasticSearch&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Core.ElasticSearch
Elasticsearch (NEST client) integration. Index management, full-text search, and CRUD operations.
Installation
// Program.cs
builder.Services.Configure<ElasticSearchConfig>(config.GetSection("ElasticSearchConfig"));
builder.Services.AddSingleton<IElasticSearch, ElasticSearchManager>();
{
"ElasticSearchConfig": {
"ConnectionString": "http://localhost:9200",
"UserName": "",
"Password": ""
}
}
Operations
// Create index
await elasticSearch.CreateNewIndexAsync(new IndexModel
{
IndexName = "products",
AliasName = "products-alias",
NumberOfReplicas = 1,
NumberOfShards = 3
});
// Insert document
await elasticSearch.InsertAsync(new ElasticSearchInsertUpdateModel
{
IndexName = "products",
Item = product
});
// Bulk insert
await elasticSearch.InsertManyAsync("products", productList.Cast<object>().ToArray());
// Update
await elasticSearch.UpdateByElasticIdAsync(new ElasticSearchInsertUpdateModel
{
IndexName = "products",
ElasticId = "elastic-doc-id",
Item = updatedProduct
});
// Delete
await elasticSearch.DeleteByElasticIdAsync(new ElasticSearchModel
{
IndexName = "products",
ElasticId = "elastic-doc-id"
});
Search
// All results (paginated)
IList<ElasticSearchGetModel<Product>> results = await elasticSearch.GetAllSearch<Product>(
new SearchParameters { IndexName = "products", From = 0, Size = 10 });
// Field-based search
IList<ElasticSearchGetModel<Product>> results = await elasticSearch.GetSearchByField<Product>(
new SearchByFieldParameters
{
IndexName = "products",
FieldName = "name",
Value = "laptop",
From = 0, Size = 10
});
// Simple query string search
IList<ElasticSearchGetModel<Product>> results = await elasticSearch.GetSearchBySimpleQueryString<Product>(
new SearchByQueryParameters
{
IndexName = "products",
QueryName = "product-search",
Fields = ["name", "description"],
Query = "gaming laptop",
From = 0, Size = 10
});
Models
ElasticSearchModel ← IndexName, ElasticId
└── ElasticSearchInsertUpdateModel ← + Item (object)
└── ElasticSearchInsertManyModel ← + Items (object[])
ElasticSearchGetModel<T> ← ElasticId + T Item (for results)
SearchParameters ← IndexName, From, Size
└── SearchByFieldParameters ← + FieldName, Value
└── SearchByQueryParameters ← + QueryName, Fields[], Query
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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.
-
net10.0
- Elastic.Clients.Elasticsearch (>= 8.19.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.