In this tutorial, we will show you how to install Elasticsearch on Ubuntu 18.04。The easiest way to install Elasticsearch on Ubuntu 18.04 is by installing the deb package from the official Elasticsearch repository.So Let's follow these steps to configure and use Elasticsearch
I am using elasticsearch 8.15.3 and nest 7.17.5 versions and .net 8.0
NEST version:7.17.5
Elasticsearch version: 8.15.3
.NET runtime version: .NET 8
Operating system version: Ubuntu 22.04
Table of Contents
We upgrade our application to .net 8, and and we also upgrade the latest NEST library: version:
<TargetFramework>net8.0</TargetFramework>
<PackageReference Include="NEST" Version="7.17.5" />
<PackageReference Include="NEST.JsonNetSerializer" Version="7.17.5" />
If i run my application in localhost, should connect to elastic server correctly.all worked with the previous version of the application.
But when we deploy the application to azure, we got an exception:
2023-12-31T15:43:47Z [Information] [15:43:46 INF] Start GetElasticDocumentQuery handling
2023-12-31T15:43:47Z [Information] [15:43:46 INF] elasticSetting: http://ip_addr:9201/
2023-12-31T15:43:47Z [Information] [15:43:46 INF] Search success: Invalid NEST response built from a unsuccessful () low level call on POST: /test-index/_search?typed_keys=true
2023-12-31T15:43:47Z [Information] # Audit trail of this API call:
2023-12-31T15:43:47Z [Information] - [1] ProductCheckOnStartup: Took: 00:00:00.0018850
2023-12-31T15:43:47Z [Information] - [2] ProductCheckFailure: Node: http://ip_addr:9201/ Took: 00:00:00.0018489
2023-12-31T15:43:47Z [Information] # OriginalException: Elasticsearch.Net.ElasticsearchClientException: The client is unable to verify that the server is Elasticsearch due to an unsuccessful product check call. Some functionality may not be compatible if the server is running an unsupported product. Call: Status code unknown from: GET /
2023-12-31T15:43:47Z [Information] ---> Elasticsearch.Net.PipelineException: The client is unable to verify that the server is Elasticsearch due to an unsuccessful product check call. Some functionality may not be compatible if the server is running an unsupported product.
step 1:Install ** on Ubuntu 22.04
step 2:install Elasticsearch 8.x on Ubuntu 22.04
Once you download and install JRE, you need to download the setup Elasticsearch and install it from below link.
official Elasticsearch Document:Install Elasticsearch with Debian Package
https://www.elastic.co/guide/en/elasticsearch/reference/current/deb.html
Step 3
Once you install Elasticsearch, check whether Elasticsearch is installed or not by hitting below url in any browser.
wget http://localhost:9200/
step 4: Install IK Analysis for Elasticsearch on Ubuntu 22.04
IK Analysis for Elasticsearch
https://github.com/medcl/elasticsearch-analysis-ik
Step 5
Either take it from this link https://www.nuget.org/packages/NEST/ OR Use Install-Package NEST -Version 6.5.0
Now you are ready to work on Elasticsearch through .NET.
Step 6
- using Nest;
Here points to note is that "index" is Database and "type" is Table. so you need to create INDEX(Database) first, then you need to create TYPE(Table) so that you can insert data in table in the format of JSON.
Step 7
BadResponse: Node: http://localhost:9200/ Took: 00:00:01.0190940
# OriginalException: Elasticsearch.Net.ElasticsearchClientException: Request failed to execute. Call: Status code 400 from: PUT /wwwiaspnetcoreindex. ServerError: Type: mapper_parsing_exception Reason: "Failed to parse mapping: Unknown parameter [boost] on mapper [Title]" CausedBy: "Type: mapper_parsing_exception Reason: "Unknown parameter [boost] on mapper [Title]"
delete boost
[Text(Name = "Body", Store = true, Index = true, Analyzer = "ik_max_word", SearchAnalyzer = "ik_smart",boost=1.5)]
useful links
https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-minimal-setup.html