ElasticLite.Client
1.0.1
dotnet add package ElasticLite.Client --version 1.0.1
NuGet\Install-Package ElasticLite.Client -Version 1.0.1
<PackageReference Include="ElasticLite.Client" Version="1.0.1" />
paket add ElasticLite.Client --version 1.0.1
#r "nuget: ElasticLite.Client, 1.0.1"
// Install ElasticLite.Client as a Cake Addin #addin nuget:?package=ElasticLite.Client&version=1.0.1 // Install ElasticLite.Client as a Cake Tool #tool nuget:?package=ElasticLite.Client&version=1.0.1
轻量版操作ElasticSearch工具
Nuget 包搜索 ElasticLite.Client 并且安装
实例化
List<string> urls = new List<string>(){ "http://localhost:9200/"};
ElasticConnection elasticConnection = new ElasticConnection(urls);
判断 index 是否存在:
bool exists = elasticConnection.Head(indexName);
创建 index, 并且设置mapping:
var result = elasticConnection.Put(indexName, mapping);
if (result.Contains("\"acknowledged\":true")) return true;
索引数据:
var result = elasticConnection.Post("person/doc/1", json);
if (result.Contains("\"successful\":1")) return true;
删除数据:
var result = elasticConnection.Delete("person/doc/1");
if (result.Contains("\"successful\":1")) return true;
搜索数据:
var result = elasticConnection.Post(indexName, json);
或者只取需要的数据
var result = elasticConnection.Post(indexName+ "/_search?filter_path=hits.total,hits.hits._source,hits.hits._id,hits.hits.highlight", json);
更新数据最佳实践:
确保id一致使用索引接口来修改
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net45 is compatible. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
改变描述