How to use Index pattern using REST API

Hi All,

How to use Index pattern to search from multiple tables using low level rest client api.

E.g , Lets assume I have following index names as:

  1. Index_2019_1
  2. Index_2019_2
  3. Index_2018_1
  4. index_2018_2

Now I want get data from Index_2019_* ( Index_2019_1 and Index_2019_2) using Java api,

I am new to ES and not sure how to use GET API to achieve this.

Please provide me some pointer or sample example would be of great help.

What I know so far is, that you can search over multiple indices:

SearchRequest searchRequest = new SearchRequest(INDEX, INDEX2)

but I think that "index pattern names" are not supported, so you have to write a logic on your own. But you can give Index_2019_1 and Index_2019_2 the same type when creating them e.g. "Index_2019" and than you can try searching over index types. That could work, hopefully.

SearchRequest searchRequest = new SearchRequest(TYPE);

SearchRequest searchRequest = new SearchRequest("Index_2019_*")

Should work AFAIK.

But note that is for the Search API not the GET API.

Thanks for Reply,

BTW, I found that Index_2019_* is also working for GET API.
i.e http://host:port/index_*/doc/_search

This is a search API call using a GET HHTP verb.
Not the GET DocumenAPI.

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