Introduction to Elasticsearch step by step

Hello!
Today we will discuss the full-text search engine Elasticsearch (hereinafter ES), which
works with the Docsvision 5.5 platform.

Introduction to Elasticsearch step by step

1. Installation

You can download the latest version from the link: www.elastic.co/downloads/elasticsearch
Screenshot of the installer below:
Introduction to Elasticsearch step by step

2. Checking functionality

After installation is complete, go to the address
http://localhost:9200/
A page displaying the status of ES should appear below:
Introduction to Elasticsearch step by step

If the page does not open, make sure that the Elasticsearch service is running. In Windows, this
is the Elasticsearch service.
Introduction to Elasticsearch step by step

3. Connecting to Docsvision

Connecting to Elasticsearch is configured on the full-text indexing service page.
Here you need to specify:
Introduction to Elasticsearch step by step

1. The address of the Elasticsearch server (set during installation).
2. The connection string to the database.
3. The address of Docsvision (in the format ConnectAddress=
asmxhttp://SERVER/DocsVision/StorageServer/StorageServerService.
4. In the 'Cards' and 'Directories' tabs, you need to configure the data that
)
needs to be indexed.
You also need to ensure that the account under which the Docsvision service
Fulltext Indexing service is running has access to the Docsvision database on MS SQL.
After connecting, make sure that tasks with the prefix:
‘DV:FullText__CardWithFilesPrepareRange’ have been created in the MS SQL database.
After completing the settings, the search box will be unlocked in the Windows client.
Introduction to Elasticsearch step by step

4. Elastic REST API

The administrator can get various information about the operation of Elasticsearch using the

provided REST API.
In the following examples, we will use Insomnia Rest Client.
Getting general information

Once the service has started and is working (http://localhost:9200/ in the browser), you can

execute the request:
You will get a response about the status of the Elasticsearch service (in the browser):
http://localhost:9200/_cat/health?v

Response about the status in Insomnia:
Introduction to Elasticsearch step by step
Let's pay attention to Status — Green, Yellow, Red. The official documentation states the following about the statuses:
Introduction to Elasticsearch step by step
• Green — All is well (Cluster fully operational)
• Yellow — All data is available, but some replicas in the cluster are not yet assigned for them
• Red — Some data is unavailable for any reason (the cluster itself is functioning normally)
Getting statuses about nodes in the cluster and their state (I have 1 node):
All ES indices:
http://localhost:9200/_cat/nodes?v
Introduction to Elasticsearch step by step

In addition to indices from Docsvision, there may be indices from other applications — heartbeat,
http://localhost:9200/_cat/indices?v
Introduction to Elasticsearch step by step

kibana — if you are using them. You can sort the necessary ones from the unnecessary. For example,
let's take only the indices that have rd% in their name:
let's take only the indexes whose names include rd% in the title:
http://localhost:9200/_cat/indices/*card*?v&s=index
Introduction to Elasticsearch step by step

Elasticsearch Configuration

Retrieving Elasticsearch settings:
http://localhost:9200/_nodes
The result will be quite extensive, including paths to the logs:
Introduction to Elasticsearch step by step

We already know how to get the list of indexes, Docsvision does this automatically, naming the index in the format:
<имябд+видИндексируемойКарточки>
It is also possible to create your own independent index:
http://localhost:9200/customer?pretty
However, this will not be a GET request, but a PUT request:
Introduction to Elasticsearch step by step

Result:
Introduction to Elasticsearch step by step

The following request will show all indexes, including the new one (customer):
http://localhost:9200/_cat/indices?v
Introduction to Elasticsearch step by step

5. Getting information on indexed data

Elasticsearch index statuses

After the initial setup from Docsvision is completed, the service should be ready to operate and begin indexing data.
First of all, let's check that the indexes are being filled and their size is larger than the standard 'bytes' using a familiar request:
http://localhost:9200/_cat/indices?v
as a result, we see: 87 'tasks' and 72 'documents' indexed, when referring to our EDM terminology:
Introduction to Elasticsearch step by step

After some time, the results are as follows (by default, the indexing job runs every 5 minutes):
Introduction to Elasticsearch step by step

We see that the number of documents has increased.

How can we tell that the required card has been indexed?

• Firstly, we need to ensure that the card type in Docsvision matches the data specified in the Elasticsearch settings.
• Secondly, wait for the indexing of the card array — it should take some time for the data to appear in the storage after being added to Docsvision.
• Thirdly, you can search for the card by CardID. This can be done with the following request:

http://localhost:9200/_search?q=_id=2116C498-9D34-44C9-99B0-CE89465637C9

If the card exists in the storage, we will see its 'raw' data, if not, we will see a response like this:
Introduction to Elasticsearch step by step

Searching for a card in the Elasticsearch node

Find a document by exact match of the Description field:
http://localhost:9200/_search?q=description: Incoming tv1
Result:
Introduction to Elasticsearch step by step

search for a document that contains 'Incoming' in the Description
http://localhost:9200/_search?q=description like Incoming
Result:
Introduction to Elasticsearch step by step

Searching for a card by the content of the attached file
http://localhost:9200/_search?q=content like 'AGILE'
result:
Introduction to Elasticsearch step by step

Let's find all cards of type document:
http://localhost:9200/_search?q=_type:CardDocument

or all cards of type task:
http://localhost:9200/_search?q=_type:CardTask

Using constructs and and parameters returned by Elasticsearch in JSON format, we can build such a request:
http://localhost:9200/_search?q=_type:CardTask and Employee_RoomNumber: Orel office and Employee_FirstName: Konstantin

It will show all task-type cards among users whose FirstName = Konstantin, located in the Orel Office.
Besides LIKE there are also other documented parameters:
unlike, fields, docs, content, etc.
They are all described here.

That's all for today!

#docsvision #docsvisionECM

Useful links:

  1. Insomnia Rest client https://insomnia.rest/download/#windows
  2. https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html
  3. https://www.elastic.co/guide/en/elasticsearch/reference/1.4/_exploring_your_data.html
  4. https://stackoverflow.com/questions/50278255/elasticsearch-backup-on-windows-and-restore-on-linux
  5. https://z0z0.me/how-to-create-snapshot-and-restore-snapshot-with-elasticsearch/
  6. https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-mlt-query.html#_document_input_parameters
  7. http://qaru.site/questions/15663281/elasticsearch-backup-on-windows-and-restore-on-linux

Source: habr.com

Buy reliable website hosting with DDoS protection, VPS VDS servers 🔥 Buy reliable website hosting with DDoS protection, VPS VDS servers | ProHoster