Introduction to Elasticsearch step by step

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

Introduction to Elasticsearch step by step

1. Installation

You can download the current version from the link: www.elastic.co/downloads/elasticsearch
Installer screenshot below:
Introduction to Elasticsearch step by step

2. Function test

After installation is complete, go to
http://localhost:9200/
The ES status page should be displayed, example below:
Introduction to Elasticsearch step by step

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

3. Connecting to Docsvision

Connection to Elasticsearch is configured on the page of the full-text service.
indexing.
Introduction to Elasticsearch step by step

Here you need to specify:
1. Elasticsearch server address (set during installation).
2. DBMS connection string.
3. Docsvision address (in the format ConnectAddress=http://SERVER/DocsVision/StorageServer/StorageServerService.
asmx
)
4. On the "Cards" and "References" tab, you need to configure the data that
needs to be indexed.
You also need to make sure that the account under which the Docsvision service is running
Fulltext Indexing service, has access to the Docsvision database on MS SQL.
After connecting, you need to make sure that tasks with the prefix were created in the MS SQL database:
"DV:FullText_<DBNAME>_CardWithFilesPrepareRange"
Introduction to Elasticsearch step by step

After completing the settings in the Windows client, the search bar will be unlocked.

4. Elastic REST API

An administrator can get various information about the operation of Elasticsearch using
provided by the REST API.
In the following examples, we will use the Insomnia Rest Client.

Getting general information

Once the service is up and running (http://localhost:9200/ in a browser), you can
execute query:
http://localhost:9200/_cat/health?v

Get a response about the status of the Elasticsearch service (in the browser):
Introduction to Elasticsearch step by step
Status response in Insomnia:
Introduction to Elasticsearch step by step
Let's pay attention to Status — Green, Yellow, Red. The official documentation says the following about statuses:
• Green - All is well (Cluster is fully functional)
• Yellow - All data is available, but some replicas in the cluster have not yet been allocated to them.
• Red - Part of the data is unavailable for any reason (the cluster itself is functioning normally)
Getting states about the nodes in the cluster and their state (I have 1 node):
http://localhost:9200/_cat/nodes?v
Introduction to Elasticsearch step by step

All indices (indices) ES:
http://localhost:9200/_cat/indices?v
Introduction to Elasticsearch step by step

In addition to indexes from Docsvision, there may be indexes of other applications - heartbeat,
kibana - if you use them. You can sort what you need from what you don't need. For example,
take only indexes that have %card% in their names:
http://localhost:9200/_cat/indices/*card*?v&s=index
Introduction to Elasticsearch step by step

Elasticsearch configuration

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

How to find out the list of indexes, we already know, Docsvision does this automatically by giving the name of the index in the format:
<database name+IndexedCard type>
You can also create your own independent index:
http://localhost:9200/customer?pretty
Only it will not be a GET, but a PUT request:
Introduction to Elasticsearch step by step

Result:
Introduction to Elasticsearch step by step

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

5. Getting information about indexed data

Status of Elasticsearch indexes

After the initial configuration by Docsvision has been completed, the service should be ready to work and start indexing data.
First of all, let's check that the indexes are filled and their size is larger than the standard "bytes" with the query already familiar to us:
http://localhost:9200/_cat/indices?v
as a result, we see: 87 “tasks” and 72 “documents” are indexed, speaking in terms of our EDMS:
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 to understand that the desired card is indexed?

• First, you need to make sure that the card type in Docsvision matches the data specified in the Elasticsearch settings.
• Secondly, wait for the array of cards to be indexed - when it gets into Docsvision, some time must pass before the data appears in the storage.
• Thirdly, you can search for a card by CardID. You can do this with a query:

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

If the card is in the storage, we will see its “raw” data, if not, we will see something like this response:
Introduction to Elasticsearch step by step

Searching for a card in an Elasticsearch node

Find a document by exact match of the Description field:
http://localhost:9200/_search?q=description: Исходящий tv1
Result:
Introduction to Elasticsearch step by step

search for a document whose Description has an entry 'Incoming'
http://localhost:9200/_search?q=description like Входящий
Result:
Introduction to Elasticsearch step by step

Search 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

Find all cards of document type:
http://localhost:9200/_search?q=_type:CardDocument

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

Using constructs and and the parameters that Elasticsearch gives in the form of JSON, you can collect such a request:
http://localhost:9200/_search?q=_type:CardTask and Employee_RoomNumber: Орёл офиc and Employee_FirstName:Konstantin

It will show all cards of the task type, among the users who have FirstName = Konstantin, and located in the Oryol Office.
But LIKE there are other documented options:
unlike, fields, docs, content, etc.
All of them are 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

Add a comment