Angular 4 ElasticSearch example – How to create an Index

In this tutorial, we’re gonna look at way to create an Elasticsearch Index in an Angular 4 Project.

Related Posts:
Angular 4 ElasticSearch – Quick Start – How to add Elasticsearch.js
Angular 4 ElasticSearch example – Add Document to Index
Angular 4 ElasticSearch example – Get All Documents in Index
Angular 4 ElasticSearch example – Documents Pagination with Scroll

Elasticsearch Tutorials:
Elasticsearch Overview
ElasticSearch Filter vs Query
ElasticSearch Full Text Queries – Basic

I. How to

1. Add ElasticSearch to Angular 4 Project

Please visit Angular 4 ElasticSearch – Quick Start – How to add Elasticsearch.js for details.

With the post, you will know how to:
– Install ElasticSearch
– Add ElasticSearch to Angular 4 Project
– Use it in the project

2. Create an ElasticSearch Index
2.1 Connect to ElasticSearch

2.2 Ping ElasticSearch

If server is available, your Browser console shows:

Now you can create an Index.

2.3 Create an ElasticSearch Index

II. Practice

Project Structure:

1. App Module

2. ElasticSearch Service

3. Add Test Component



4. App Component



5. Check Result

Run Angular 4 App, go to http://localhost:4200/:

Open Browser Console, we can see:

Fill index in the box (for example: jsa_index) and press Submit button, we can see:
– in Browser Console:

– in ElasticSearch Console:

III. Sourcecode


By grokonez | October 13, 2017.

Last updated on August 14, 2018.

Related Posts

Got Something To Say:

Your email address will not be published. Required fields are marked *