Angular 6 ElasticSearch example – Get All Documents in Index

We had known way to add Document to Elasticsearch Index, this tutorial shows you how to get all Documents and show them.

Related Posts:
Angular 6 ElasticSearch – Quick Start – How to add Elasticsearch.js
Angular 6 ElasticSearch example – Add Document to Index
– Next:
+ Angular 6 ElasticSearch example – Documents Pagination with Scroll
+ Angular 6 ElasticSearch example – simple Full Text Search

**Elasticsearch Tutorials**

Get all Documents in Elasticsearch Index

Add ElasticSearch to Angular 6 Project

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

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

Add Document to Index


Please visit Angular 6 ElasticSearch example – Add Document to Index for details.

Get All Documents in Index
ElasticSearch Service

The response of search() function should be like:

Component to implement

With CustomerSource interface:

In HTML, we get Customer from CustomerSource._source:


0. Overview



1. Generate Service & Components

Run cmd:
ng g s elasticsearch
ng g c customer/add-customer
ng g c customer/customer-details
ng g c customer/show-customers

=> Project Structure:


2. App Module


3. ElasticSearch Service


4. Components


4.1 Add Document Component

Please visit: 4_Add_Document_Component (in the previous post) for details.

4.2 Details Component



4.3 Show Documents Component



5. App Routing Module


6. App Component



7. Check Result

Run Angular 6 App, go to http://localhost:4200/, add Customer Data, then choose Customers tab:


Open Browser Console, you can see:



By grokonez | August 15, 2018.

Related Posts

1 thought on “Angular 6 ElasticSearch example – Get All Documents in Index”

  1. Your code is very helpful. I appreciate it so much. I was wondering if you would know how to search using “elasticsearch-browser”: “^16.2.0” for a specific field in an index and get back only non duplicates of that field?

    I am currently getting documents back from elasticsearch and then I loop on the documents, creating a Set of a particular field (deduping) from that response, however I have it set to retrieve 150 documents, but when I get the zip code field for example, there are tons of duplicates and then since I only got 150 responses, when I dedupe those, I am left with very few fields to display to the user. I would like to display (with a scroll bar), all of the zip codes (up to a count of 150).

    Thank you so much!!!


Got Something To Say:

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