Home > Back-end >  Opensearch Java Client is not showing up the creation date of an index in a _cat request
Opensearch Java Client is not showing up the creation date of an index in a _cat request

Time:12-07

Opensearch Java Client Versions:

  • opensearch-rest-client (2.4.0)
  • opensearch-java (2.1.0)

Description:

I’m using a _cat request to get some information about the indices through the opensearch java client. When I check the response, the creation date of the index is not coming up.

https://i.stack.imgur.com/WbXjN.png

As you can see, the creationDate of the index is not coming out.

If I make the request directly to elasticsearch, I get the creation date, as you can see below.

https://i.stack.imgur.com/iixRg.png

Is this a bug ??? Why the creation date of the index is not coming out in the opensearch java client

I'm trying to get index information, but I can't get the creation date using the opensearch java client

CodePudding user response:

You can try use GetIndexRequest.

var response = client.indices().get(i -> i.index("idx_name"));
var createDate = response.get("idx_name").settings().index().creationDate();
    
Timestamp stamp = new Timestamp(Long.parseLong(createDate.toString()));
Date date = new Date(stamp.getTime());
System.out.println(date);

CodePudding user response:

After test al the possible ways, I just ended using a rest call using the Springboot WebClient. The OpenSearch Java Client is very immature right now. There are some task that we can implement without any problem, but there are a lot of incomplete work in his implementation

  • Related