Reddy SK
Reddy SK

Reputation: 1374

How to search in elasticsearch indexes starting with a string

I am still new with elasticsearch and trying to find the best way how to filter results from a range of indices.

i.e.: Filebeat and logstash use to create index per day. I use to use bot for an different purpose and parallel I am using a posix shell script which is parsing and indexing some files from archive. Hence I have 3 types of indexes:

archive and logs are generated with date in the name:

I have tried various of attempts, but no success.

How to build the URI if I want to search only in logs or only in archive?

Many thanks Regards Reddy

Upvotes: 1

Views: 159

Answers (1)

bittusarkar
bittusarkar

Reputation: 6357

You can use wildcards in the index name. If you want to search all documents in indices whose name start with "logs", the corresponding query is:

POST logs*/_search
{
    "query": {
        "match_all": {}
    }
}

Read this for more information.

Upvotes: 2

Related Questions