Description

This knowledge article explains how to search and view data from an Elasticsearch index.

Solution

>> To show/list the indices 

# curl -XGET 'http://localhost:9222/_cat/indices?v';
health status index    uuid                   pri rep docs.count docs.deleted store.size pri.store.size
yellow open   security sYGyXhLtTki4QM7r7kFd6w   2   1      34615            0     18.6mb         18.6mb

Index name: security
 

>> To list data of an Elasticsearch index

# curl -XGET 'http://localhost:9222/security/_search?pretty'

Note: The security index contains a couple of fields, and has example ~1000 entries, but typically an index will contain huge amounts of data. As a result, in most cases you would need to paginate and search the data.
 

>> Paginate search query 

# curl -XGET 'http://localhost:9222/security/_search?size=100'

Note: The size parameter has a limit of 10,000. This will show 100 hits. 
 

>> To show the next page with 100 hits, you can call:

# curl -XGET 'http://localhost:9222/security/_search?size=100&from=100'
 

>> For filter search results

Example: If you wanted to search specific object details = 52.247.150.191 then run below query 

# curl -XGET 'http://localhost:9222/security/_search?q="52.247.150.191/32"'

 

>> Single Query Search:
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query.html
https://logz.io/blog/elasticsearch-queries/#:~:text=Elasticsearch%20Terms%20Query

 
>> Multiple Query Search:
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html#query-dsl-bool-query
https://logz.io/blog/elasticsearch-queries/#:~:text=Copy-,Compound%20Queries,-Boolean%20Operators%20and

 
>> Types of Queries:
https://www.elastic.co/guide/en/elasticsearch/reference/current/term-level-queries.html#term-level-queries
(Most common query is the “Term” query from my experience)

 

Note : If you face any issues, please contact JUNIPER JTAC Support for assistance.

Modification History

Article Created: 17 Feb 2024