![]() |
VOOZH | about |
dotnet add package Galosys.Foundation.Elastic --version 26.5.20.1
NuGet\Install-Package Galosys.Foundation.Elastic -Version 26.5.20.1
<PackageReference Include="Galosys.Foundation.Elastic" Version="26.5.20.1" />
<PackageVersion Include="Galosys.Foundation.Elastic" Version="26.5.20.1" />Directory.Packages.props
<PackageReference Include="Galosys.Foundation.Elastic" />Project file
paket add Galosys.Foundation.Elastic --version 26.5.20.1
#r "nuget: Galosys.Foundation.Elastic, 26.5.20.1"
#:package Galosys.Foundation.Elastic@26.5.20.1
#addin nuget:?package=Galosys.Foundation.Elastic&version=26.5.20.1Install as a Cake Addin
#tool nuget:?package=Galosys.Foundation.Elastic&version=26.5.20.1Install as a Cake Tool
成熟度: 🟡 可用 — 功能完整,测试或文档可能不完善
Galosys.Foundation.Elastic 是对 Elasticsearch 8.0 客户端的封装,提供基于 Microsoft.Extensions.DependencyInjection 的依赖注入支持,简化在 .NET 应用中集成 Elasticsearch 的配置和使用。
dotnet add package Galosys.Foundation.Elastic
在 appsettings.json 中添加 Elasticsearch 配置:
{
"Elasticsearch": {
"Uris": [ "http://localhost:9200" ],
"UserName": "your-username",
"Password": "your-password"
}
}
在 Program.cs 或 Startup.cs 中注册 Elasticsearch 服务:
using Microsoft.Extensions.DependencyInjection;
var builder = WebApplication.CreateBuilder(args);
// 添加 Elasticsearch 服务
builder.Services.AddElastic8_0();
var app = builder.Build();
var product = new Product { Id = "1", Name = "示例产品", Price = 99.99m };
var response = await _client.IndexAsync(product, idx => idx
.Index("products")
.Id(product.Id));
var response = await _client.GetAsync<Product>("1", g => g.Index("products"));
if (response.IsSuccess)
{
var product = response.Source;
}
var response = await _client.DeleteAsync("products", "1");
var response = await _client.SearchAsync<Product>(s => s
.Index("products")
.Query(q => q
.Match(m => m
.Field(f => f.Name)
.Query("示例")
)
)
);
foreach (var product in response.Documents)
{
Console.WriteLine(product.Name);
}
var response = await _client.SearchAsync<Product>(s => s
.Index("products")
.Query(q => q
.Bool(b => b
.Must(m => m
.Match(t => t
.Field(f => f.Name)
.Query("示例")
)
)
.Filter(f => f
.Range(r => r
.NumberRange(n => n
.Field(f => f.Price)
.Gte(50)
.Lte(200)
)
)
)
)
)
.Size(10)
.From(0)
.Sort(so => so
.Field(f => f.Price, f => f.Order(SortOrder.Asc))
)
);
| 类 | 说明 |
|---|---|
ElasticsearchClient |
Elasticsearch 8.0 客户端实例,用于执行索引、搜索等操作 |
ElasticsearchOptions |
配置选项类,包含 Uris、UserName、Password 属性 |
ElasticServiceCollectionExtensions |
依赖注入扩展类,提供 AddElastic8_0() 方法 |
ElasticModule |
内部模块类,实现 IModule 接口用于自动注册 |
ArgumentNullException| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. 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. |
Showing the top 1 NuGet packages that depend on Galosys.Foundation.Elastic:
| Package | Downloads |
|---|---|
|
Galosys.NETCore.Base
Galosys.Foundation快速开发库 |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 26.5.20.1 | 96 | 5/20/2026 |
| 26.5.19.1 | 102 | 5/19/2026 |
| 26.5.18.1 | 97 | 5/18/2026 |
| 26.5.15.1 | 89 | 5/15/2026 |
| 26.5.12.3 | 89 | 5/12/2026 |
| 26.5.12.2 | 93 | 5/12/2026 |
| 26.4.27.1-rc1 | 92 | 4/26/2026 |
| 26.4.25.1-rc1 | 90 | 4/25/2026 |
| 26.4.22.2-rc7 | 102 | 4/22/2026 |
| 26.4.22.2-rc6 | 92 | 4/22/2026 |
| 26.4.22.2-rc4 | 97 | 4/22/2026 |
| 26.4.22.2-rc3 | 94 | 4/22/2026 |
| 26.4.19.1-rc1 | 98 | 4/19/2026 |
| 26.4.12.8-rc1 | 115 | 4/12/2026 |
| 26.4.12.7-rc1 | 111 | 4/12/2026 |
| 26.4.12.5-rc1 | 95 | 4/12/2026 |
| 26.1.30.1-rc1 | 133 | 1/30/2026 |
| 26.1.29.1 | 137 | 1/29/2026 |
| 26.1.28.5 | 127 | 1/28/2026 |
| 26.1.28.4 | 130 | 1/28/2026 |