API with NestJS #12. Introduction to Elasticsearch

API with NestJS #12. Introduction to Elasticsearch

Relational databases might be slow when searching through a lot of data. A solution to the above problem might be Elasticsearch.

We can find some searching functionalities in a lot of web applications. While we might be fine when iterating through a small data set, the performance for more extensive databases can become an issue. Relational databases might prove to be relatively slow when searching through a lot of data.

A solution to the above problem might be Elasticsearch. It is a search engine that highly focuses on performance. When using it, we maintain a separate document-oriented database.

If you are familiar with MongoDB, document-oriented databases will ring a bell for you. In theory, we might use Elasticsearch as a general-purpose database. It wasn’t designed for this purpose, though. If you would like to read more about it, check out this question on Stackoverflow.

Running Elasticsearch

Running Elasticsearch includes maintaining a separate, search-optimized database. Because of that, we need to choose one of the ways to fire it up.

In the second part of this series, we’ve started using Docker Compose. Therefore, a fitting way to start using Elasticsearch would be to do so through Docker. When we go to the official Elasticsearch documentation, we can see an example using Docker Compose. It includes three nodes.

An Elasticsearch cluster is a group of one or more Elasticsearch *nodes *connected. Each node is an instance of Elasticsearch.

Let’s add the above official configuration to our existing file.

####### docker-compose.yml

version :    "3"

 services :

    postgres :

      container_name :    postgres

      image :    postgres : latest

      ports :

        -    "5432:5432"

      volumes :

        -    / data / postgres :/ data / postgres

      env_file :

        -    docker . env

      networks :

        -    postgres

    pgadmin :

      links :

        -    postgres : postgres

      container_name :    pgadmin

      image :    dpage / pgadmin4

      ports :

        -    "8080:80"

      volumes :

        -    / data / pgadmin :/ root / . pgadmin

      env_file :

        -    docker . env

      networks :

        -    postgres

    es01 :

      image :    docker . elastic . co / elasticsearch / elasticsearch : 7.9.1

     container_name:    es01

      environment :

        -    node . name = es01

        -    cluster . name = es - docker - cluster

        -    discovery . seed_hosts = es02 , es03

        -    cluster . initial_master_nodes = es01 , es02 , es03

        -    bootstrap . memory_lock =**true**

        -    "ES_JAVA_OPTS=-Xms512m -Xmx512m"

      ulimits :

        memlock :

          soft :    - 1

         hard:    - 1

     volumes:

        -    data01 :_/usr/s_ hare / elasticsearch / data

      ports :

        -    9200 : 9200

     networks:

        -    elastic

    es02 :

      image :    docker . elastic . co / elasticsearch / elasticsearch : 7.9.1

     container_name:    es02

      environment :

        -    node . name = es02

        -    cluster . name = es - docker - cluster

        -    discovery . seed_hosts = es01 , es03

        -    cluster . initial_master_nodes = es01 , es02 , es03

        -    bootstrap . memory_lock =**true**

        -    "ES_JAVA_OPTS=-Xms512m -Xmx512m"

      ulimits :

        memlock :

          soft :    - 1

         hard:    - 1

     volumes:

        -    data02 :_/usr/s_ hare / elasticsearch / data

      networks :

        -    elastic

    es03 :

      image :    docker . elastic . co / elasticsearch / elasticsearch : 7.9.1

     container_name:    es03

      environment :

        -    node . name = es03

        -    cluster . name = es - docker - cluster

        -    discovery . seed_hosts = es01 , es02

        -    cluster . initial_master_nodes = es01 , es02 , es03

        -    bootstrap . memory_lock =**true**

        -    "ES_JAVA_OPTS=-Xms512m -Xmx512m"

      ulimits :

        memlock :

          soft :    - 1

         hard:    - 1

     volumes:

        -    data03 :_/usr/s_ hare / elasticsearch / data

      networks :

        -    elastic

 volumes :

    data01 :

      driver :    local

    data02 :

      driver :    local

    data03 :

      driver :    local

 networks :

    postgres :

      driver :    bridge

    elastic :

      driver :    bridge

javascript nestjs typescript

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Building Modern Nodejs Application using Nestjs and TypeScript

Building Modern Nodejs Application using Nestjs and TypeScript - In this article, we will see how to build REST API using Nestjs with TypeScript. Building Modern Nodejs Application using Nestjs and TypeScript

Developing REST API Framework using TypeScript and NestJS

Nowadays, web applications are being designed with REST API and front-end. For developing a UI application, now, we have so many popular JavaScript frameworks available, like Angular, React, Vue and many more. For developing REST API, we have multiple options too. If we select Java as a programming language, we have Spring boot; for .NET, we have REST API Framework; if we choose JavaScript, then we have ExpressJS, HapiJS, and NestJS etc

The essential JavaScript concepts that you should understand

The essential JavaScript concepts that you should understand - For successful developing and to pass a work interview

Por qué DEBES aprender TYPESCRIPT (Typescript vs Javascript)

Habéis oido hablar de TypeScript? Porqué se está utilizando y qué aporta que no tenga JavaScript? Se puede utilizar con Angular o con React? En el backend? En éste vídeo os explico porqué utilizo TypeScript y cómo instalarlo!

Builder Pattern in JavaScript/TypeScript

This article is not just about Builder Pattern in JS/TS, I will be explaining my thought process behind it and see if you can relate yourself to this. I believe everybody has a unique way of solving problems, hope you get something to learn from it.