Hi, I'm trying to query solr indexer thru a web page and trying to display the result. I've the following class to query solr [I'm using the query(string) method],
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.SolrServerException; import org.apache.solr.client.solrj.SolrQuery; import org.apache.solr.client.solrj.response.QueryResponse; import org.apache.solr.client.solrj.response.FacetField; import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer; public class SolrjTest { public String query(String q) { CommonsHttpSolrServer server = null; try { server = new CommonsHttpSolrServer("http://localhost:8983/solr/ "); } catch(Exception e) { e.printStackTrace(); } SolrQuery query = new SolrQuery(); query.setQuery(q); query.setQueryType("dismax"); 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("--------------------------------"); //System.out.println("Result doc : " + sdl); return sdl.toString(); } catch (SolrServerException e) { e.printStackTrace(); return null; } } } and the following to pass the queries to solr, get results and display it on the browser, import java.applet.Applet; import java.awt.Graphics; import java.awt.Font; public class ControlJava extends Applet { Font f = new Font("TimesRoman", Font.BOLD, 20); String Message; public void init() { Message = new String("ubuntu"); } public void SetMessage(String MsgText) { SolrjTest solr = new SolrjTest(); Message = solr.query(MsgText); repaint(); } public void paint(Graphics g) { g.setFont(f); g.drawString(Message, 15, 50); } } and finally the html page is this, <HTML> <HEAD> <TITLE>Control a Java Applet</TITLE> </HEAD> <BODY> <H1>Control a Java Applet</H1> <HR> The Java applet below displays text in a large font. You can enter new text to display in the form below, and JavaScript will call the Java applet to change the text. <HR> <FORM NAME="form1"> <INPUT TYPE="TEXT" NAME="text1"> <INPUT TYPE="BUTTON" VALUE="Change Text" onClick="document.ControlJava.SetMessage(document.form1.text1.value);"> </FORM> <HR> <APPLET NAME="ControlJava" CODE="ControlJava.class" WIDTH=450 HEIGHT=125> </APPLET> <HR> End of page. </BODY> </HTML> When I'm trying to access this page and putting the query in the box that this html shows, the browser [IE] gives some error and after checking I found that the error is some class not found exception, its not able to find the org.apache.*.*.... classes and hence giving errors. Now instead of calling that I wrote a simpe class not using any apache.solr classes and called the method therein [just returns a string] and it worked fine. I added both both the classes [.class files] given above to the same location where this web page resides. The problem is that browser is not able to find those org.apache.*** classes and creating the mess. Can anyone help this newbie fixing the problem. Thanks a lot. Do let me know if some information is missing/want some extra information on this issue. --Ahmed.