Reputation: 233
I have a three index, all three index have a diff structure of document(nested), I tried to join the index's,But in ES there is no joins.So, how can i get the data from multiple index's through java high level api??
Any help will be appreciate, thanks in adavnce
SearchRequest searchRequest = new SearchRequest("index_1","index_2","index_3");
SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
sourceBuilder.query(QueryBuilders.termQuery("user", "kimchy"));
SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);
Upvotes: 0
Views: 2145
Reputation: 38552
You can query multiple Elasticsearch indices in one search operation. The indices can be specified with wildcard patterns, or by listing multiple indices using commas as separators.
But with Client API(Java high level api), You've to convert the index names inside SearchRequest
into an array of Strings. Java varargs
expects an Array. Not sure but something like below.
String[] indexArray = new String[]{"index_1","index_2","imdex_3"}
SearchRequest searchRequest = new SearchRequest(indexArray);
If it doesn't help the try with Multisearch API, See: https://www.elastic.co/guide/en/elasticsearch/client/java-rest/master/java-rest-high-multi-search.html#java-rest-high-multi-search
Upvotes: 0