how to search in multi cluster (cross cluster search) by using java high level rest client?
Welcome!
Search the same way you are searching with local indices.
https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-cross-cluster-search.html
Hi,
I am trying to develop a spring boot based elasticsearch project and I am trying to use Java High Level Rest Client in the same.
I am initializing the client like this:
RestHighLevelClient client = new RestHighLevelClient(RestClient.builder(HTTP_LOCAL_HOSTS));
BoolQueryBuilder query = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("field", value));
SearchSourceBuilder builder = new SearchSourceBuilder();
builder.query(query);
SearchRequest req = new SearchRequest("test_index1");
req.source(builder);
return client.search(req, RequestOptions.DEFAULT);
"HTTP_LOCAL_HOSTS" is local cluster nodes and my config for remote cluster correctly.
"test_index1" exist in remote cluster and have multiple records with "field: value" but this query don't return result.
Please help me out.
You need to provide a more concrete example, like a document which should match, the mapping, the value you are passing to the term query...
Also test_index1
means that you are searching in the local cluster.
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.