Hi, again, gang.

I'm writing a test program using Restlet 2.1-SNAPSHOT JEE, running as a Servlet 
in Tomcat, and trying to query a SOLR instance.  (SOLR is running on the same 
Tomcat instance, if that's relevant.)  I feel like I'm pretty close, and I've 
tried to understand the documentation, but I must be missing something 
important.  I can't get a response when I try to handle a request using the 
SOLR client.

Here's the relevant part of what I'm trying to do with this.  My guess is that 
I'm not understanding how to configure the CoreContainer correctly, but I could 
certainly be missing something else.  If anyone can point out what I have 
messed up, I'd be very grateful!  Thanks!


Adding SOLR client support:

public class MyComponent extends Component
{
    @Override
    public void start()
    {
        getClients().add(Protocol.FILE);
        getClients().add(Protocol.CLAP);
        Client solrClient = getClients().add(SolrClientHelper.SOLR_PROTOCOL);

        File config = new File("/usr/share/solr/conf/solrconfig.xml");
        CoreContainer coreContainer = new CoreContainer("/web/index/data/", 
config);
        solrClient.getContext().getAttributes().put("CoreContainer", 
coreContainer);

        getDefaultHost().attach(new MyApp());
        super.start();
      }
}

Tying component into Servlet (this appears to work, because the function above 
gets called, and the rest of the app runs:

   <servlet>  
      <servlet-name>RestletServlet</servlet-name>  
      <servlet-class>org.restlet.ext.servlet.ServerServlet</servlet-class>
        <init-param>
        <!-- Component class name -->
        <param-name>org.restlet.component</param-name>
        <param-value>com.my.stuff.MyComponent</param-value>
     </init-param>   
   </servlet>  

Calling (I've tried every core name I can think of, including none.  There's 
currently a core0 and a core1 specified in solr.xml.):

            Request request = new Request(Method.GET, "solr://core0/select/?q=" 
+ strSearchTerms);
            Response resp = 
Context.getCurrent().getClientDispatcher().handle(request);           
            
            if (resp != null)
            {
                Representation rep = resp.getEntity();
                if (rep == null)
                {
                    System.out.println("Rep = <null>");
                    System.out.println("Status = " + 
resp.getStatus().getCode());
                    System.out.println("Status = " + 
resp.getStatus().getDescription());

This handle() call returns a status 500, and the description says, "no such 
core: core0".  I've tried everything I can think of to figure out what the 
right core name, if any, I ought to be using - including using no core name.  
When I add a bunch of code to dump the contents of the CoreContainer that's in 
the SOLR client, I find that it doesn't contain any cores.  I suspect it ought 
to, and that I've missed a step in the configuration.

Any thoughts?

---------------------------------------------------------------
John Wismar
Architect - ALLDATA Technology
john.wis...@alldata.com
916-478-3296

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2676906

Reply via email to