Querying already indexed data in different computer


(Kartik) #1

In elastic search java api, suppose I am building the indexed data using this client

Node node = nodeBuilder().clusterName("./resources/firstcommit").node();
Client client = node.client();
IndexResponse response = client.prepareIndex("twitter", "tweet", "1")
.setSource(jsonBuilder()
.startObject()
.field("user", "kimchy")
.field("postDate", new Date())
.field("message", "trying out Elasticsearch")
.endObject()
)
.execute()
.actionGet();

This indexed data is stored in folder XYZ/resources/firstcommit.
My question is how to query this indexed data in java on some other client on other computer.
Is there any way in which I can give the path and the already indexed data can be imported, then I can perform queries on it?

I copied the whole data folder on other computer and ran the following code on other computer. This gave the following exception

Node node = nodeBuilder().clusterName("./resources/firstcommit").node();
Client client = node.client();
MatchQueryBuilder qb = QueryBuilders.matchQuery("user", "kimchy");
SearchRequestBuilder srb = client.prepareSearch("twitter").setTypes("tweet");
SearchResponse big = srb.setQuery(qb).execute().actionGet();
SearchHit[] results = big.getHits().getHits();

This shows

search.SearchPhaseExecutionException: Failed to execute phase [query], all shards failed


(system) #2