HI ,
Iam using transport client 5.4.3 version with elastic search 5.4.3 version and java as 1.8 but iam unable to connect to the server with trasport client .
TransportClient client = new PreBuiltTransportClient(Settings.EMPTY).addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("server"), 9300));
iam getting error in PreBuiltTransportClient as Resource Path Location Type PreBuiltTransportClient cannot be resolved to a type UserRest.java .
can anyone please help me with the correct way to fix this issue . i couldn't find the exact solution for this .
iam trying to get search response this way as i need to get all the location where this file is stored :
client = new PreBuiltTransportClient(settings).addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("address"), 9300)); QueryBuilder qb = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("file.filename", "J.K.Rowling- Harry Potter and the Sorcerer's Stone.txt"));
SearchResponse scrollResp = client.prepareSearch("ftp_folder")
.addSort(FieldSortBuilder.DOC_FIELD_NAME, SortOrder.ASC)
.setScroll(new TimeValue(60000))
.setQuery(qb)
.setSize(100).execute().actionGet();
System.out.println("scrollResp"+scrollResp);
but the response format that iam getting is : {"took":307,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":38,"max_score":2.5529227,"hits":[{"_index":"ftp_public","_type":"doc","_id":"b8f8207a434a4dfc7221a5a4a8a6c3c","_score":2.5529227,"_source":{
Hi ,
what iam trying here is ,the documents are already indexed on elastic search server and i need to write a search query to get those documents as a result on based of the query hit . iam trying with the below code
client = new PreBuiltTransportClient(settings).addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("host"), 9300));
QueryBuilder qb = QueryBuilders.termQuery("file.filename", "hary potter");
SearchResponse scrollResp = client.prepareSearch("ftp_public_fscrawler")
.setScroll(new TimeValue(60000))
.setQuery(qb)
.setSize(100).execute().actionGet();
while (true) {
//Break condition: No hits are returned
if (scrollResp.getHits().getHits().length == 0) {
break;
}
for (SearchHit hit : scrollResp.getHits().getHits()) {
JSONObject value = new JSONObject(hit.getSource());
but iam not able to get search response in proper json format .
no iam not able to get the correct response that iam looking for : when iam giving query as :J.K.Rowling- Harry Potter and the Sorcerer's Stone.txt . iam getting json response as below
{
"took" : 306,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 23,
"max_score" : 8.506227,
"hits" : [
{
"_index" : "ftp_public_fscrawler_from_russia_folder",
"_type" : "doc",
"_id" : "69db39631b623ad6ab3cc7ec45b8d92",
"_score" : 8.506227,
"_source" : {
"root" : "7a1652c1448c3164dea76c4adfc2ea",
"virtual" : "/English/English Audiobooks/Harry Potter/Harry Potter - Book3",
"real" : "\\ftp\ftp\Public\English\English Audiobooks\Harry Potter\Harry Potter - Book3"
}
},
{
"_index" : "ftp_public_fscrawler_from_russia_folder",
"_type" : "doc",
"_id" : "f5cd60ae3fd2e040bdecc8e3e6949daa",
"_score" : 8.506227,
"_source" : {
"root" : "7a1652c1448c3164dea76c4adfc2ea",
"virtual" : "/English/English Audiobooks/Harry Potter/Harry Potter - Book4",
"real" : "\\ftp\ftp\Public\English\English Audiobooks\Harry Potter\Harry Potter - Book4"
}
},
i cant see the query keyword in this jSON response . how can i retrieve it . when iam checking the same with SENSE then iam getting the correct response
yes i have this document and i want this to come in search response but if u will check the json response posted above i cant see that to be there . how can i get other fields like source,content from searchquery .
i have tried String virtual = (String)hit.getSource().get("virtual") which is giving me folder location .
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.