Dan
Dan

Reputation: 1033

Spring-data-elastic and get "_index" value

We are slowly moving our project away from the RestHighLevelClient onto Spring's Api Client. In doing so it looks as though some of the metadata is not coming back as expected.

Here's our simplified POJO:

public class TestDocument {

   @Field(name="_index")
   private String index;

   ...
}

Previously, when using the RestHighLevelClient the field was populated without any issues, however now the value is coming back as null.

My search query is very simple as well. Here's how we're doing it:

SearchHits<TestDocument> hits = esClient.search(query, TestDocument.class, IndexCoordinates.of(index);

Any thoughts on how to populate that property?

Upvotes: 0

Views: 200

Answers (1)

Abacus
Abacus

Reputation: 19471

There is no Api Client from Spring. Spring Data Elasticsearch now uses the (new) Elasticsearch Java CLient.

What do you expect in _index? The name of the index where the document was retrieved from? That was never mapped by Spring Data Elasticsearch onto a property, but it is returned in each SearchHit<T>

Upvotes: 0

Related Questions