Showing posts with label Elasticsearch. Show all posts
Showing posts with label Elasticsearch. Show all posts

Wednesday, July 21, 2021

Postman to query Elasticsearch

To query elasticsearch result, that is use GET method with JSON data. Generally in REST API, we don't have body data in the GET method.

 



Tuesday, June 08, 2021

Elasticsearch

I have my elasticsearch in my window services. I only start up this service when I need it.

To see all elasticsearch index in the local, open browser to
http://localhost:9200/_cat/indices?v

To view a particular index data, open browser to
http://localhost:9200/[index name]/_search

For example: my earthquakes data
http://localhost:9200/earthquakes/_search
The data is in hits.hits.

 

Use bulk function to insert multiple records.
To avoid the data duplication when inserting, apply the same _id.

    let body = earthquakes.flatMap(
        obj => [{ index: { _index: INDEX_id: obj.id } }, obj]
    );
    let results = await client.bulk({ 
        refresh: true,
        body
    });