Automated indices and its fields tests

(Alexander Tunick) #1

Sorry in advance if this question has been already asked.
But reading the official documentation did not help me:
I would like to test indices, its fields, number of records in it

So, the goal:
Automatically check indices and its fields on right records and its quantity to run it locally or putting in into CI. Preferably using Javascript.

I see that it's possible to do via Elastic REST API but can't figure out how to construct a request.

I have {url} EC2 instance where elastic is being laid.
There exists:
Index: persons
fields: capacity, address

I want to make a request to retrieve number of records from capacity and address

(Jon Budzenski) #2

There's a few parts here, I would start with pulling down the javascript client:

In addition to that we'll need to construct a query for elasticsearch. The querying docs can be found in the elasticsearch section -

An example of a search:

curl -X GET "localhost:9200/persons/_search" -H 'Content-Type: application/json' -d'
    "query": {
        "match_all": {}

This is saying search all documents in my persons index.

And for example if you want to make sure the fields capacity and address exist:

curl -X GET "localhost:9200/persons/_search" -H 'Content-Type: application/json' -d'
  "query": {
    "bool": {
        { "exists": { "field": "capacity" } },
        { "exists": { "field": "address" } }


(Alexander Tunick) #3

@jbudz Hi. Sorry for long-term answer delay. I have read it, but did not have time to proceed the information and try something with it.
Got, I will try to figure out with this all.
Thank you!

(system) #4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.