Table of Contents
Install Elasticsearch 8.15
不能用root用户启动,报“Caused by: java.lang.RuntimeException: can not run elasticsearch as root”.
https://blog.csdn.net/m0_54219225/article/details/130667081
Elastic.Clients.Elasticsearch version:8.15.3
Elasticsearch version: 8.15.3
.NET runtime version: .NET 8
Operating system version: Ubuntu 22.04
Install Elasticsearch
Install IK
dotnet add package Elastic.Clients.Elasticsearch --version 8.11.0
es7.x和es8.x版本差异比较大
es7和es8的高亮就非常不一样。
Elasticsearch 8.x .NET - Elastic.Clients.Elasticsearch
We have released the next generation of the .NET client for Elasticsearch, which aligns with v8 of Elasticsearch.
We have renamed this library Elastic.Clients.Elasticsearch, and the packages are published on NuGet
https://www.elastic.co/guide/en/elasticsearch/client/net-api/8.15/source-serialization.html
https://www.elastic.co/guide/en/elasticsearch/client/net-api/8.13/connecting.html
Elasticsearch:使用最新的 Elasticsearch Java client 8.0 来创建索引并搜索
我们在学习ES客户端时,一直使用的都是Java High Level Rest Client,在浏览官网时,发现官方给出的警告是:Java REST 客户端已被弃用,取而代之的是 Java API client 客户端,ES 8.x 新版本中,Type 概念被弃用,所以新版 JavaAPI 也相应做出了改变,使用更加简便。ES 官方从 7.15 起开始建议使用新的 JavaAPI
如何使用最新的 Elasticsearch Java client 8.0 来创建索引并进行搜索。最新的 Elasticsearch Java client API 和之前的不同。在es7的一些教程中,经常使用 High Level API 来进行操作。但在官方文档中,已经显示为 deprecated。
Java API Client
官网为啥又推出一个新的客户端接口呢,这是为了统一管理,官网给出的回应是:将来只对这个客户端进行维护改进,这也接口会更加的清晰明了,可读性更高,更易于上手,更简单!代码看着更加简洁了!
无论是ElasticsearchTemplate类还是ElasticsearchRepository接口,都是对ES常用的简单功能进行封装,在实际使用时,复杂的查询语法还是依赖ElasticsearchClient和原生的API封装;
更详细内容参考官网API文档:https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/package-structure.html
Elasticsearch 8.15.3 on ubuntu 24.04
Releases · elastic/elasticsearch-net · GitHub https://github.com/elastic/elasticsearch-net
Releases · elastic/elasticsearch-net · GitHub
Migration guide: From NEST v7 to .NET Client v8
https://github.com/infinilabs/analysis-ik
sudo vi /etc/elasticsearch/elasticsearch.yml
Using the .NET Client
生成证书指纹
https://blog.csdn.net/willingtolove/article/details/137780194
Semantic Search
you can'nt use attribute mapping .
I'm trying to write a mapping function using V8 client library. But there is not much i can configure. For example in the NEST V7, i can specify analyzer, multifields to a certain field via fluent mapping:
'''
.Text(tt => tt
.Name(zazzleStemmerAnalyzer)
.Analyzer(zazzleStemmerAnalyzer)
.SearchAnalyzer(zazzleStemmerAnalyzer))
But there is no way to add any specification to mapping in V8 client library. The only thing i can do is to map a field to a type:
'''
.Mappings(mappings => mappings.Properties(p => p
.LongNumber(e => e.Id)
.Text(t => t.Title)))
we’re creating an index named ‘flights’ with custom type mappings
var descriptor = new CreateIndexRequestDescriptor(indexName).
Mappings(m => m
.Properties(new Properties
{
{"FlightNum", new TextProperty() {Analyzer = "standard"}},
{"FlightCode", new KeywordProperty {IgnoreAbove = 6}}
}));
var response = await _client.Indices.CreateAsync(descriptor, cancellationToken);
return response.IsValidResponse;
https://hamedsalameh.com/full-text-search-with-elasticsearch-and-netcore/
Exception: Invalid NEST response built from a unsuccessful () low level call on PUT: /wwwindex # Audit trail of this API call
ES 8.x新特性
https://blog.csdn.net/star1210644725/article/details/134126478
Install Elasticsearch 9.14
Install
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg
sudo apt-get install apt-transport-https
echo "deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/9.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-9.x.list
sudo apt-get update && sudo apt-get install elasticsearch
or
apt-get install elasticsearch=9.1.4
output
Creating elasticsearch group... OK
Creating elasticsearch user... OK
Unpacking elasticsearch (9.1.4) ...
Setting up elasticsearch (9.1.4) ...
--------------------------- Security autoconfiguration information ------------------------------
Authentication and authorization are enabled.
TLS for the transport and HTTP layers is enabled and configured.
The generated password for the elastic built-in superuser is : OIs8AueU6yJBuywZFD*Z
If this node should join an existing cluster, you can reconfigure this with
'/usr/share/elasticsearch/bin/elasticsearch-reconfigure-node --enrollment-token <token-here>'
after creating an enrollment token on your existing cluster.
You can complete the following actions at any time:
Reset the password of the elastic built-in superuser with
'/usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic'.
Generate an enrollment token for Kibana instances with
'/usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s kibana'.
Generate an enrollment token for Elasticsearch nodes with
'/usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s node'.
-------------------------------------------------------------------------------------------------
### NOT starting on installation, please execute the following statements to configure elasticsearch service to start automatically using systemd
sudo systemctl daemon-reload
sudo systemctl enable elasticsearch.service
### You can start elasticsearch service by executing
sudo systemctl start elasticsearch.service
detail:https://www.elastic.co/docs/deploy-manage/deploy/self-managed/install-elasticsearch-with-debian-package
Configuration
output
curl -X GET "localhost:9200/"
{
"name" : "debian",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "xtNEuvEeRVmtK9iCT2WWyQ",
"version" : {
"number" : "9.1.4",
"build_flavor" : "default",
"build_type" : "deb",
"build_hash" : "0b7fe68d2e369469ff9e9f344ab6df64ab9c5293",
"build_date" : "2025-09-16T22:05:19.073893347Z",
"build_snapshot" : false,
"lucene_version" : "10.2.2",
"minimum_wire_compatibility_version" : "8.19.0",
"minimum_index_compatibility_version" : "8.0.0"
},
"tagline" : "You Know, for Search"
}
Elasticsearch .NET 客户端的演变
Elasticsearch 8.13 版本发布,官方宣布了 v7 NEST 的弃用。
Elasticsearch .NET 客户端过渡到v8 Elastic.Clients.Elasticsearch
Elasticsearch .NET client evolution: From NEST to Elastic.Clients.Elasticsearch after Elasticsearch 8.13
Elasticsearch .NET Client
GitHub 上的 Elastic.Clients.Elasticsearch v8 客户端 https://github.com/elastic/elasticsearch-net
Compatibility
Elasticsearch .NET Client 9.x 只支持 Elasticsearch .NET 9.x 10.X
https://github.com/elastic/elasticsearch-net