java - solrj error: array out of bounds -
hi im trying run code , can seem figure out wrong..sorry im new solrj
import org.apache.solr.common.solrdocument; import java.util.map; import org.apache.solr.common.solrdocumentlist; import org.apache.solr.common.solrdocument; import java.util.map; import java.util.iterator; import java.util.list; import java.util.arraylist; import java.util.hashmap; import org.apache.solr.client.solrj.solrserver; import org.apache.solr.client.solrj.solrserverexception; import org.apache.solr.client.solrj.solrquery; import org.apache.solr.client.solrj.impl.commonshttpsolrserver; import org.apache.solr.client.solrj.impl.httpsolrserver; import org.apache.solr.client.solrj.response.queryresponse; import org.apache.solr.client.solrj.response.facetfield; public class solrjtest { public void query(string q) { //commonshttpsolrserver server = null; solrserver server = null; try { server = new httpsolrserver("http://localhost:8983/solr/"); //server = new commonshttpsolrserver("http://localhost:8080/solr/"); system.out.println("connected"); } catch(exception e) { system.out.println("not connected"); e.printstacktrace(); } solrquery query = new solrquery(); query.setquery(q); query.setquerytype("camera"); query.setfacet(true); query.addfacetfield("name"); query.addfacetfield("locality4"); query.setfacetmincount(2); query.setincludescore(true); try { queryresponse qr = server.query(query); solrdocumentlist sdl = qr.getresults(); system.out.println("found: " + sdl.getnumfound()); system.out.println("start: " + sdl.getstart()); system.out.println("max score: " + sdl.getmaxscore()); system.out.println("--------------------------------"); arraylist<hashmap<string, object>> hitsonpage = new arraylist<hashmap<string, object>>(); for(solrdocument d : sdl) { hashmap<string, object> values = new hashmap<string, object>(); for(iterator<map.entry<string, object>> = d.iterator(); i.hasnext(); ) { map.entry<string, object> e2 = i.next(); values.put(e2.getkey(), e2.getvalue()); } hitsonpage.add(values); system.out.println(values.get("displayname") + " (" + values.get("displayphone") + ")"); } list<facetfield> facets = qr.getfacetfields(); for(facetfield facet : facets) { list<facetfield.count> facetentries = facet.getvalues(); for(facetfield.count fcount : facetentries) { system.out.println(fcount.getname() + ": " + fcount.getcount()); } } } catch (solrserverexception e) { e.printstacktrace(); } } public static void main(string[] args) { solrjtest solrj = new solrjtest(); solrj.query(args[0]); } }
im having error
exception in thread "main" java.lang.arrayindexoutofboundsexception: 0 @ solrjtest.main(solrjtest.java:98)
and pointing in:
solrj.query(args[0]);
i have additional question cause before im having output whenever run sample program in solrj
{time=218.0,sub1={time=125.0,sub1.1={time=31.0}}}
can tell me means , error array out of bounds? in advance need badly , dont know solrj
the reason not supplying runtime parameters while program execution starts.
in solrj.query(args[0]);
, args
refers parameters passed program like:
java myclass abc def
so here in above case args
:
args[0] -----> "abc" args[1] -----> "def"
so make sure passing proper parameters while executing program.
Comments
Post a Comment