Just jumping in this thread.
To have some information on how to build requests using Java API.
Hope this help.
i did like this..
SearchResponse response = client.prepareSearch().setIndices("_river").setTypes("dc_user_river").execute().actionGet();
output is
{
"took" : 16,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : 1.0,
"hits" : [ {
"_index" : "_river",
"_type" : "dc_user_river",
"_id" : "_meta",
"_score" : 1.0, "_source" : { "type": "mongodb", "mongodb": { "db": "data-collection", "collection": "DC_USER" }, "index": { "name": "dc_user_idx", "type": "DC_USER" }}
}, {
"_index" : "_river",
"_type" : "dc_user_river",
"_id" : "_status",
"_score" : 1.0, "_source" : {"ok":true,"node":{"id":"Snvd2nvCQB-4hpKUvMQtqA","name":"Jaeger","transport_address":"inet[/192.168.10.2:9300]"}}
} ]
}
}
On Monday, March 11, 2013 6:34:34 PM UTC+5:30, simonw wrote:
ok so are you sure you have a 'dc_user_river' type?
what happens if your remove the query entirely and just filter by the 'dc_user_river' type?
simon
On Monday, March 11, 2013 1:59:22 PM UTC+1, srikanth gone wrote:
hi simonw,
if i use this code..
SearchResponse response = client.prepareSearch().execute().actionGet();
System.out.println(response);
SearchHit results = response.getHits().getHits();
System.out.println(results);
for (SearchHit hit : results) {
System.out.println(hit.getId()); //prints out the id of the document
result = hit.getSource(); //the retrieved document
}
i am getting this output.
{
"took" : 63,
"timed_out" : false,
"_shards" : {
"total" : 91,
"successful" : 91,
"failed" : 0
},
"hits" : {
"total" : 122,
"max_score" : 1.0,
"hits" : [ {
"_index" : "_river",
"_type" : "dc_demo_group_river",
"_id" : "data-collection.DC_DEMO_GROUP",
"_score" : 1.0, "_source" : {"mongodb":{"_last_ts":"{ "$ts" : 1362465631 , "$inc" : 1}"}}
}, {
"_index" : "_river",
"_type" : "dc_provider_river",
"_id" : "_meta",
"_score" : 1.0, "_source" : { "type": "mongodb", "mongodb": { "db": "data-collection", "collection": "DC_PROVIDER" }, "index": { "name": "dc_provider_idx", "type": "DC_PROVIDER" }}
}, {
"_index" : "_river",
"_type" : "dc_practice_river",
"_id" : "_meta",
"_score" : 1.0, "_source" : { "type": "mongodb", "mongodb": { "db": "data-collection", "collection": "DC_PRACTICE" }, "index": { "name": "dc_practice_idx", "type": "DC_PRACTICE" }}
}, {
"_index" : "_river",
"_type" : "dc_patient_topic_river",
"_id" : "_meta",
"_score" : 1.0, "_source" : { "type": "mongodb", "mongodb": { "db": "data-collection", "collection": "DC_PATIENT_TOPIC_DATA" }, "index": { "name": "dc_patient_topic_data_idx", "type": "DC_PATIENT_TOPIC_DATA" }}
}, {
"_index" : "_river",
"_type" : "dc_patient_river",
"_id" : "_meta",
"_score" : 1.0, "_source" : { "type": "mongodb", "mongodb": { "db": "data-collection", "collection": "DC_PATIENT" }, "index": { "name": "dc_patient_idx", "type": "DC_PATIENT" }}
}, {
"_index" : "_river",
"_type" : "dc_demo_jursidiction_river",
"_id" : "data-collection.DC_DEMO_JURISDICTION",
"_score" : 1.0, "_source" : {"mongodb":{"_last_ts":"{ "$ts" : 1362465631 , "$inc" : 1}"}}
}, {
"_index" : "_river",
"_type" : "dc_demo_rule_metadata_river",
"_id" : "_meta",
"_score" : 1.0, "_source" : { "type": "mongodb", "mongodb": { "db": "data-collection", "collection": "DC_RULES_METADATA" }, "index": { "name": "dc_rule_metadata_idx", "type": "DC_RULES_METADATA" }}
}, {
"_index" : "_river",
"_type" : "dc_role_river",
"_id" : "_meta",
"_score" : 1.0, "_source" : { "type": "mongodb", "mongodb": { "db": "data-collection", "collection": "DC_ROLE" }, "index": { "name": "dc_role_idx", "type": "DC_ROLE" }}
}, {
"_index" : "_river",
"_type" : "dc_demo_group_river",
"_id" : "_meta",
"_score" : 1.0, "_source" : { "type": "mongodb", "mongodb": { "db": "data-collection", "collection": "DC_DEMO_GROUP" }, "index": { "name": "dc_demo_group_idx", "type": "DC_DEMO_GROUP" }}
}, {
"_index" : "_river",
"_type" : "dc_topic_river",
"_id" : "_meta",
"_score" : 1.0, "_source" : { "type": "mongodb", "mongodb": { "db": "data-collection", "collection": "DC_TOPIC" }, "index": { "name": "dc_topic_idx", "type": "DC_TOPIC" }}
} ]
}
}
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.