HMENetCore.Elasticsearch 6.0.47

dotnet add package HMENetCore.Elasticsearch --version 6.0.47
                    
NuGet\Install-Package HMENetCore.Elasticsearch -Version 6.0.47
                    
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="HMENetCore.Elasticsearch" Version="6.0.47" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="HMENetCore.Elasticsearch" Version="6.0.47" />
                    
Directory.Packages.props
<PackageReference Include="HMENetCore.Elasticsearch" />
                    
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 HMENetCore.Elasticsearch --version 6.0.47
                    
#r "nuget: HMENetCore.Elasticsearch, 6.0.47"
                    
#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 HMENetCore.Elasticsearch@6.0.47
                    
#: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=HMENetCore.Elasticsearch&version=6.0.47
                    
Install as a Cake Addin
#tool nuget:?package=HMENetCore.Elasticsearch&version=6.0.47
                    
Install as a Cake Tool

HMENetCore.Elasticsearch

简介

HMENetCore.Elasticsearch 是一个基于 Elasticsearch.Net、NEST (Elasticsearch 7.0) 的封装库,提供了对 Elasticsearch 的常用操作封装,包括索引管理、文档增删改查、批量操作、分页查询、滚动查询、SQL查询等功能.

功能特性

  • 完整的CRUD操作封装
  • 支持批量操作(插入、更新、删除)
  • 丰富的查询方式(精确匹配、模糊匹配、分页查询等)
  • 支持SQL查询
  • 支持滚动查询(Scroll API)
  • 支持聚合查询(Aggregations)
  • 索引管理功能
  • 依赖注入友好设计
  • 线程安全

运行环境

  • 跨平台支持: Supports .NET Standard 2.1, .NET 6, .NET 8, and .NET 9.

安装

dotnet add package HMENetCore.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 Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  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 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 is compatible.  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.

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
6.0.47 128 8/13/2025
6.0.46 209 8/7/2025
6.0.45 120 7/16/2025
6.0.42 140 6/18/2025
6.0.40 273 6/10/2025
6.0.39 233 5/15/2025
6.0.32 181 4/9/2025
6.0.31 157 3/17/2025
6.0.30 125 2/19/2025
6.0.20 113 2/5/2025
6.0.18 107 1/6/2025
6.0.11 117 12/9/2024
6.0.8 115 11/15/2024
6.0.6 178 10/18/2024
6.0.2 122 10/9/2024
6.0.1 165 8/16/2024