Getting Started with Elasticsearch
Connect to your Data
Metadata creation
To create a Elasticsearch Metadata, launch the Metadata creation wizard, select the Elasticsearch Metadata in the list and follow the wizard.
Then, configure the server properties.
Example:
The following server properties are available.
Property | Description |
---|---|
Name |
Elastic Search Server name (you can give any name, it is a label for the metadata). |
Elasticsearch Version |
Elasticsearch server version, which will be used to know which API to use. This is mandatory. |
Transport Addresses |
Comma separated list of addresses that will be used for data operations with the java API, using the following format:
|
Cluster Name |
Elasticsearch cluster name |
Path Home |
Elasticsearch installation path on the server. |
Http URL |
HTTP URL that will be used for reverse operations on the cluster. |
Http User |
HTTP user which will be used when performing reverse operations on the cluster. |
Http Password |
HTTP password which will be used when performing reverse operations on the cluster. |
Define and Reverse Indexes
To define an Index and reverse it:
-
Right click on the server node and choose New > Index
-
Fill-in the Index properties
Example:
The following properties are available:
Property | Description |
---|---|
Name |
Logical name for the Index. You can give any name, it is a label for the Metadata. |
Index Name |
Elasticsearch physical name of the index. |
Reverse Size |
Number of documents retrieved to analyze the structures. |
Reverse from |
The offset from which the reverse will fetch the documents. |
Aliased Indexes |
The list of indexes the Alias is pointing to, when the specified 'Index Name' is an Alias. It is filled automatically at reverse. |
The Component supports both using the real name of an Index, or an Alias Name pointing to this index.
|
If the Index Name property matches an existing index or alias on the server, you can right click on it and select Actions > Reverse All to reverse all the document types of the index. As the reverse is done through parsing the document structures, one document, at least, must exist on the server for being able to reverse its type. The Reverse All action can also be used for updating the already existing Metadata if you already reversed it. In this case, note that if you have multiple document metadata with the same Document Type Name, only the first will be updated. |
From Elasticsearch 7.x servers and higher, document types are deprecated and only one is allowed per index. |
Define and Reverse Document Types
Overview
To define manually a Document Type:
-
Right click on an Index node and choose New > Type
-
Fill-in the Document Type properties
Example:
The following properties are available:
Property | Description |
---|---|
Name |
Logical name for the Type. You can give any name, it is a label for the Metadata. |
Document Type Name |
Elasticsearch physical name of the document type. This is the name that will be used for data and reverse operations. It is mandatory. |
If the Document Type Name property matches an existing Document in the Index, you can right click on it and select Actions > Reverse to reverse it. As the reverse is done through parsing the document structures, one document, at least, must exist on the server for being able to reverse its structure. |
From Elasticsearch 7.x servers and higher, document types are deprecated and only one is allowed per index. |
Document Type Structure
The structure of a Document is a JSON structure.
You can define it manually, if you are designing a Document Type that does not exist yet.
To define manually the structure of a Document Type, right click on the type and choose new > [Object | Value | Array].
|
Example of an Elasticsearch Document structure
Joined Documents
Elasticsearch offers the ability to join documents.
This allows to define parent / child relation between documents.
You can work with such documents in Semarchy xDI:
-
On your Document Type, add on the root node a new value named "routing".
-
Define it as a "string" value.
You can then map this field inside your Elasticsearch Mappings. |
Define and Reverse Search queries
Common query
A Search Query is a placeholder that will contain an Elasticsearch query.
It is used to retrieved data from a predefined query.
To define a Search Query:
-
Right click on the server node and choose New > Search
-
Specify the search properties
-
Finally, right click on the search node and choose Actions > reverse. This will execute the query and parse the response to get the structure returned.
Example:
The following properties are available:
Property | Description |
---|---|
Name |
Label for the search query. |
Indexes |
Comma separated list of Indexes on which the query will be executed |
Doc types |
Comma separated list of document types on which the query will be executed |
Query |
Elasticsearch query to execute, with the JSON format. Refer to the Elasticsearch documentation for further information on how to design it. |
Parametrized query
The values of Search queries can be parametrized with the use of parameters, which allows to dynamically change the query at execution.
To parametrize a query:
-
Create a 'Value' on the search query with right click > new > Value
-
Fill-in its properties
-
Use it in the query to replace a manually set value
Example:
The following properties are available:
Property | Description |
---|---|
Name |
Label for the parametrized value, which will next be used in the query |
Reverse Value |
Default value that should be used when reversing the query |
Type |
JSON Type (string, boolean, number) |
Size |
Size used for the target staging column when using this value as source in a mapping. |
Scale |
Number of decimals for the target staging column when using this value as source in a Mapping. |
Example:
The parametrized values only work to replace values, not keys. |
Create your first Mappings
Document operations
Overview
Document types can be used as targets in Mappings to create, read, update or delete documents.
Below, a quick overview of an Elasticsearch Mapping.
To perform an operation on a document type in a Mapping, drag and drop it from your Metadata.
Then, map the root node from a source database, and select the operation to perform on the Template.
Other fields are mapped from the source to the target as usual in any Mapping. |
It is mandatory to map the root node, which is the repetition key. It will impact the amount of time Elasticsearch will be invoked. |
Use the result of the operation
You can retrieve and use the result of the Elasticsearch operation.
To do this, map the fields into a target datastore.
Work with joined Documents
To work with joined Documents, map or specify a value on the routing field.
The parent and child Documents must have the same routing value to create a relation between them.
Additional notes on Documents
There are some important notes to have in mind while making operations on Elasticsearch, which are listed below:
The root Document Type node must be mapped on the Mapping. |
The 'id' node, which is on the first level, must be mapped.
|
The index or the type can be overridden on the Mapping with the dedicated fields which are on the first level. It offers the possibility to set dynamically which index or type to use during the execution of the Mapping. |
Query operations
In a Mapping, a query operation is used the same way as a Document Operation.
Drag and drop the query from the Metadata into the Mapping, and map the root node from a source database:
As for Document operation, you must map the root node. |
If you created parametrized values for your query, you can map them from the sources or set manual values on them. |
To retrieve the result of the query, map the fields into a target datastore:
Sample Project
The Elasticsearch Component ships sample project(s) that contain various examples and use cases.
You can have a look at these projects to find samples and examples describing how to use it.
Refer to Install Components to learn how to import sample projects.