Reputation: 1695
hello i have got strange error while using solr query result. now i am add simple txt file with one word 'anna', restart solr server and next try search that document. But i haven't got any result ? but if i add another document with content 'anna' and then restart solr. I have got only one result. So there is a bug in solr or i do not know something ?
I am using luke and everything is fine i have got two indexed document and when i try this query using luke everything is fine i have got 2 result. I am also check my for loop but its everything fine with that. So maybe some problem with solrj ?? I am using solr-core , and solrj ver 4.4.0. This is my code :
QueryResponse qr;
try {
qr = fs.execute(solrServer);
System.out.println("QYERY RESPONSE : " + qr);
for (Entry<String, Object> r : qr.getResponse()) {
System.out.println("RESPONSE: " + r.getKey() + " -> " + r.getValue());
}
SolrDocumentList dl = qr.getResults();
System.out.println("--RESULT SIZE:[ " + dl.size() );
} catch (SolrServerException e) {
e.printStackTrace();
}
And it is very strange because this is my sysout:
{numFound=2,start=1,docs=[SolrDocument{file_id=9882, file_name=luk-search2.txt, file_create_user=-1, file_department=10, file_mime_type=text/plain, file_extension=.txt, file_parents_folder=[5021, 4781, 341, -20, -1], version=1442647024934584320}]}
Num found is 2 but i have got only one result so ther is a bug in solrj library ?
Upvotes: 0
Views: 82
Reputation: 22555
In looking at the response, it shows a start=1
value that is being passed in. The default value for start is 0, please see the CommonQueryParameters for reference. Since you only have two results for your query, and the start value is zero based, by specifying start=1
you are asking for only the second document. Change this parameter to start=0
and you will get both results back.
Upvotes: 1