Documentation

gitHub

Elasticsearch

Elasticsearch is a RESTful search and analytics engine based on Apache Lucene. It provides a distributed, multi-tenant-capable full-text search engine with an HTTP web interface and schema-free JSON documents. Elasticsearch is developed alongside a data-collection and log-parsing engine called Logstash, and an analytics and visualization platform called Kibana. The three products are designed for use as an integrated solution, referred to as the "Elastic Stack" (formerly the "ELK stack").

To perform data modeling for Elasticsearch with Hackolade, you must first download the Elasticsearch plugin. Important note: with v7, a new typeless API has been introduced, and the old APIs that accept types have been deprecated (more details in Moving from types to typeless APIs in Elasticsearch 7.0.) As a result a different plugin is required, depending on whether you're running ES v2;0 thru 6.!, or ES v7.0 and above. Please make sure to use the appropriate plugin.

Hackolade was specially adapted to support the data modeling of Elasticsearch, including the large choice of data types and parent-child relationships. The application closely follows the terminology of the database.

The data model in the picture below results from the reverse-engineering of a sample travel application imported in Elasticsearch.

Elasticsearch workspace

Indices

An index is similar to a database of keyspace. The term index should not be confused a database index. And the word indexing in Elasticsearch means inserting/updating the documents in an Elasticsearch index. An index is a flat collection of independent documents. A single document should contain all of the information that is required to decide whether it matches a search request.

Types

A type is similar to a database table or collection. An index can have one or more types. Type is a logical separation of different kinds of data. You should avoid putting documents that have totally different structures into the same index in order to avoid sparsity. It is often better to put these documents into different indices, you could also consider giving fewer shards to these smaller indices since they will contain fewer documents overall.

When mixing different types of documents into the same index (in ES versions prior to 6.0), it becomes necessary to specify a "type" attribute to differentiate the various documents stored in the index. In Hackolade, each Document Type is modeled as a separate entity or box, so its attributes can be defined separately. A specific attribute name must be identified to differentiate the different document types. The unique key and the document type field are common to all document types in the collection, and displayed at the top of each box in the ERD document:

Elasticsearch meta-fields

Important

Indices created in Elasticsearch 6.0.0 or later may only contain a single mapping type. Indices created in 5.x with multiple mapping types will continue to function as before in Elasticsearch 6.x. Mapping types have been completely removed in Elasticsearch 7.0. If you want to mix different document types within the same index, then you should specify a field (typically called "type") within each document to define the logical entity represented.

IDs

IDs in Elasticsearch can be provided by the application or automatically generated by Elasticsearch. Even if the id represents an integer, it is stored as a string.

Attributes data types

Elasticsearch supports a number of different datatypes for the fields in a document, including core, complex, geo, and specialized datatypes. Hackolade has been configured to use all the Elasticsearch types, as described in Field data types in the Elasticsearch documentation.

Elasticsearch data types Elasticsearch geo-point sub-typesElasticsearch geo-shape subtypes

Elasticsearch linestring structure

Analyzers

The analyzer dropdown lists the most common built-in analyzers of Elasticsearch. It appears for string fields with the text sub-type, and for completion and token_count fields.

With the Elasticsearch v7 and above plugin, the easiest way to use any other analyzer is to select custom in the dropdown, then type the analyzer's name in the analyzer name property. Hackolade Studio writes this name in the analyzer parameter of the field mapping. The name can be:

  • a built-in analyzer of Elasticsearch that the dropdown does not list. For example, of the language analyzers, the dropdown lists only english and french, but you can type spanish or german;
  • an analyzer you define in the Analyzers property of the index, for example a language analyzer with your own stop words. Hackolade Studio writes it in the analysis settings of the index.

If your team uses the same built-in analyzer regularly, you can add it to the dropdown, so that nobody has to select custom and type its name each time. Redefine the analyzer property in your custom properties, as described in Change a property of the plugin. It takes a little more work, because you must share the custom properties configuration with everyone on the team, but the analyzer is then available directly in the dropdown. The string, completion and token_count data types each have their own analyzer property: redefine it for each data type where you need the new value.

Forward-Engineering

Hackolade dynamically generates the mapping for the document structure created with the application.

The script can also be exported to the file system via the menu Tools > Forward-Engineering, or via the Command-Line Interface.

Elasticsearch forward-engineering mappings

Reverse-Engineering

You may define the connection parameters to your instance, typically on port 9200. Take a look at Connect to an Elasticsearch instance for more information.

The Hackolade reverse-engineering process of an Elasticsearch instance includes a query for a representative random sample of items, followed by a schema inference based on the sample.

For more information on Elasticsearch in general, please consult the website.