HMEFramework.Elasticsearch
2.8.0
dotnet add package HMEFramework.Elasticsearch --version 2.8.0
NuGet\Install-Package HMEFramework.Elasticsearch -Version 2.8.0
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="HMEFramework.Elasticsearch" Version="2.8.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="HMEFramework.Elasticsearch" Version="2.8.0" />
<PackageReference Include="HMEFramework.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 HMEFramework.Elasticsearch --version 2.8.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: HMEFramework.Elasticsearch, 2.8.0"
#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 HMEFramework.Elasticsearch@2.8.0
#: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=HMEFramework.Elasticsearch&version=2.8.0
#tool nuget:?package=HMEFramework.Elasticsearch&version=2.8.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
HMEFramework.Elasticsearch 7.0
简介
HMEFramework.Elasticsearch 是一个基于 Elasticsearch.Net、NEST (Elasticsearch 7.0) 的封装库,提供了对 Elasticsearch 的常用操作封装,包括索引管理、文档增删改查、批量操作、分页查询、滚动查询、SQL查询等功能.
功能特性
- 完整的CRUD操作封装
- 支持批量操作(插入、更新、删除)
- 丰富的查询方式(精确匹配、模糊匹配、分页查询等)
- 支持SQL查询
- 支持滚动查询(Scroll API)
- 支持聚合查询(Aggregations)
- 索引管理功能
- 依赖注入友好设计
- 线程安全
运行环境
- 跨平台支持: Supports .NET Standard 2.1, .NET 6+.
安装
dotnet add package HMEFramework.Elasticsearch
配置数据库连接
添加配置到 appsettings.json:
{
"ElasticSearchConfig": {
"Uris ": ["http://server1:9200","http://server2:9200"],
"UserName": "user",
"PassWord": "pwd",
"DefaultIndex": "default_index",
"EnableTls": false
}
}
服务注册
builder.Services.Configure<ElasticSearchConfig>(builder.Configuration.GetSection("ElasticSearchConfig"));
builder.Services.AddElasticSearchSetup(builder.Configuration.Get<ElasticSearchConfig>()!);
使用案例:
1.定义实体
[Table("person_index")]
public class Person
{
public string Id { get; set; }
public string Name { get; set; }
public int Age { get; set; }
public string Description { get; set; }
public DateTime CreateTime { get; set; }
}
2.创建仓储
public class PersonRepository : BaseElasticSearchRepository<Person>
{
public PersonRepository(IElasticSearchContext context) : base(context)
{
}
}
3.业务服务
public class PersonService : BaseElasticSearchService<Person>
{
public PersonService(IElasticSearchCRUD<Person> repostory) : base(repostory)
{
}
}
核心组件
1. IElasticSearchContext
提供对 ElasticSearchContext 的基本操作接口。
2. BaseElasticSearchRepository
仓储层基类,实现了 IElasticSearchCRUD 接口,提供对特定实体的 CRUD 操作。
3. BaseElasticSearchService
服务层基类,封装了仓储层的操作,可以在此基础上添加业务逻辑。
版本兼容性
基于 Elasticsearch.Net v7.x 兼容 .NET 6.0 及以上版本 兼容 Elasticsearch 7.x 版本
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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 was computed. 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. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.1
- HMEFramework (>= 2.8.0)
- Microsoft.Extensions.Options (>= 10.0.2)
- NEST (>= 7.17.5)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on HMEFramework.Elasticsearch:
| Package | Downloads |
|---|---|
|
HMEFramework.Repository
HMEFramework.Repository for .net core |
GitHub repositories
This package is not used by any popular GitHub repositories.