JSONArray jArray = new JArray();
jArray.add("jhon");
jArray.add("jerry");
jArray.add("sam");
JSONObject jObject = new JSONObject();
jObject.add("first",jArray);
For Searching I am writing following code:
SearchResponse searchResponse = client.prepareSearch("twitter")
.setSearchType(SearchType.DEFAULT)
.setQuery(wildcardQuery("first","j*"))
.setFrom(0).setSize(60).setExplain(true)
.execute()
.actionGet();
SearchHits sh = searchResponse.getHits();
System.out.println("Total Hits are sh.totalHits() : "+sh.hits().length);
I have not done any configuration what ever is default.
My Problems are:
I am getting only 1 hit but it should give 2 because (as I understand) j* will search jhon and jerry
How can i get the value of the hit( for eg if jhon is found then how can i get printed jhon)
If i make any change in the JSONObject and run the program the changes are not reflected in one time i need to run once again.
I have spent lots of time in finding the reasons for these but I could not get.
Please help to resolve the problem
May be title doesnot suite the problem, sorry for that
JSONArray jArray = new JArray();
jArray.add("jhon");
jArray.add("jerry");
jArray.add("sam");
JSONObject jObject = new JSONObject();
jObject.add("first",jArray);
For Searching I am writing following code:
SearchResponse searchResponse = client.prepareSearch("twitter")
.setSearchType(SearchType.DEFAULT)
.setQuery(wildcardQuery("first","j*"))
.setFrom(0).setSize(60).setExplain(true)
.execute()
.actionGet();
SearchHits sh = searchResponse.getHits();
System.out.println("Total Hits are sh.totalHits() :
"+sh.hits().length);
I have not done any configuration what ever is default.
My Problems are:
I am getting only 1 hit but it should give 2 because (as I understand)
j*
will search jhon and jerry
Each document you index is a hit. You might want to index a document per
name in this case.
How can i get the value of the hit( for eg if jhon is found then how can
i get printed jhon)
From the SearchHits, you can get a SearchHit, and then get back the actual
raw bytes, or a parsed map (of maps) representing the json structure.
If i make any change in the JSONObject and run the program the changes
are not reflected in one time i need to run once again.
You need to reindex the data. If you want to update a document, make sure
you use the same id. Note that search visibility is near real time, you can
issue a refresh command (client.admin.indices.prepareRefresh) to make sure
you search on what was indexed up to that point.
I have spent lots of time in finding the reasons for these but I could not
get.
Please help to resolve the problem
May be title doesnot suite the problem, sorry for that
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.