Re: Is there a clean way to determine whether a core exists?

2008-12-05 Thread Dean Thompson
Wow -- thanks for all the help!!  With everyone's help, I did end up  
in a *much* better place:


private static boolean solrCoreExists(String coreName, String  
solrRootUrl) throws IOException, SolrServerException

{
CommonsHttpSolrServer adminServer = new  
CommonsHttpSolrServer(solrRootUrl);
CoreAdminResponse status =  
CoreAdminRequest.getStatus(coreName, adminServer);


return status.getCoreStatus(coreName).get(instanceDir) !=  
null;

}


On Dec 5, 2008, at 1:09 AM, Ryan McKinley wrote:


yes:
http://localhost:8983/solr/admin/cores?action=STATUS

will give you a list of running cores.  However that is not easy to  
check with a simple status != 404


see:
http://wiki.apache.org/solr/CoreAdmin


On Dec 4, 2008, at 11:46 PM, Chris Hostetter wrote:



: Subject: Is there a clean way to determine whether a core exists?

doesn't the CoreAdminHandler's STATUS feature make this easy?




-Hoss







Is there a clean way to determine whether a core exists?

2008-12-04 Thread Dean Thompson
The ping command gives me a 500 status if the core exists, or a 404 if  
it doesn't.  For example, when I hit


http://doom:8983/solr/content_item_representations_20081201/admin/ping

I see

HTTP ERROR: 500

INTERNAL_SERVER_ERROR

RequestURI=/solr/admin/ping

Powered by Jetty://

(Obviously I'm using Jetty.  Moving to Tomcat is on our list.)

I could depend on this behavior, but that seems ugly, so I decided to  
try a probe query instead.


I am using the Solrj client library.  Unfortunately, for core non- 
existence or any other problem, Solrj uses an unhelpful catch-all  
exception:


/** Exception to catch all types of communication / parsing  
issues associated with talking to SOLR

  *
  * @version $Id: SolrServerException.java 555343 2007-07-11  
17:46:25Z hossman $

  * @since solr 1.3
  */
public class SolrServerException extends Exception {
...
}

So I have wound up, thus far, with the following code:

private boolean solrCoreExists(String url)
throws SolrException, MalformedURLException,  
SolrServerException

{
try {
SolrQuery solrQuery = new SolrQuery();
solrQuery.setQuery(xyzzy=plugh);
new CommonsHttpSolrServer(url).query(solrQuery);
return true;
} catch (SolrServerException e) {
if (e.getCause() != null   
e.getCause().getMessage().startsWith(Not Found)) {

return false;
} else {
throw e;
}
}
}

Hopefully there's a better solution?

Dean



Re: Is there a clean way to determine whether a core exists?

2008-12-04 Thread Ryan McKinley

what about just calling:
http://doom:8983/solr/content_item_representations_20081201/select

That should give you a 404 if it does not exist.

the admin stuff will behave funny if the core does not exist (perhaps  
you can file a JIRA issue for that)


ryan


On Dec 4, 2008, at 3:38 PM, Dean Thompson wrote:

The ping command gives me a 500 status if the core exists, or a 404  
if it doesn't.  For example, when I hit


   http://doom:8983/solr/content_item_representations_20081201/admin/ping

I see

   HTTP ERROR: 500

   INTERNAL_SERVER_ERROR

   RequestURI=/solr/admin/ping

   Powered by Jetty://

(Obviously I'm using Jetty.  Moving to Tomcat is on our list.)

I could depend on this behavior, but that seems ugly, so I decided  
to try a probe query instead.


I am using the Solrj client library.  Unfortunately, for core non- 
existence or any other problem, Solrj uses an unhelpful catch-all  
exception:


   /** Exception to catch all types of communication / parsing  
issues associated with talking to SOLR

 *
 * @version $Id: SolrServerException.java 555343 2007-07-11  
17:46:25Z hossman $

 * @since solr 1.3
 */
   public class SolrServerException extends Exception {
   ...
   }

So I have wound up, thus far, with the following code:

   private boolean solrCoreExists(String url)
   throws SolrException, MalformedURLException,  
SolrServerException

   {
   try {
   SolrQuery solrQuery = new SolrQuery();
   solrQuery.setQuery(xyzzy=plugh);
   new CommonsHttpSolrServer(url).query(solrQuery);
   return true;
   } catch (SolrServerException e) {
   if (e.getCause() != null   
e.getCause().getMessage().startsWith(Not Found)) {

   return false;
   } else {
   throw e;
   }
   }
   }

Hopefully there's a better solution?

Dean





Re: Is there a clean way to determine whether a core exists?

2008-12-04 Thread Dean Thompson

Thanks for the quick response, Ryan!

Actually, my admin/ping call gives me a 404 if the core doesn't exist,  
which seemed reasonable.  I get the 500 if the core *did* exist.


Thanks for the suggestion of using the select URL, but that gives me:

HTTP ERROR: 500

null

java.lang.NullPointerException
at org.apache.solr.common.util.StrUtils.splitSmart(StrUtils.java:37)
	at  
org.apache.solr.search.OldLuceneQParser.parse(LuceneQParserPlugin.java: 
104)

at org.apache.solr.search.QParser.getQuery(QParser.java:88)
	at  
org 
.apache 
.solr.handler.component.QueryComponent.prepare(QueryComponent.java:82)
	at  
org 
.apache 
.solr 
.handler.component.SearchHandler.handleRequestBody(SearchHandler.java: 
148)
	at  
org 
.apache 
.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java: 
131)

at org.apache.solr.core.SolrCore.execute(SolrCore.java:1204)
	at  
org 
.apache 
.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:303)
	at  
org 
.apache 
.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:232)
	at org.mortbay.jetty.servlet.ServletHandler 
$CachedChain.doFilter(ServletHandler.java:1089)
	at  
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:365)
	at  
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java: 
216)
	at  
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
	at  
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:712)
	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java: 
405)
	at  
org 
.mortbay 
.jetty 
.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java: 
211)
	at  
org 
.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java: 
114)
	at  
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)

at org.mortbay.jetty.Server.handle(Server.java:285)
	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java: 
502)
	at org.mortbay.jetty.HttpConnection 
$RequestHandler.headerComplete(HttpConnection.java:821)

at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:513)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:208)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:378)
	at org.mortbay.jetty.bio.SocketConnector 
$Connection.run(SocketConnector.java:226)
	at org.mortbay.thread.BoundedThreadPool 
$PoolThread.run(BoundedThreadPool.java:442)


RequestURI=/solr/content_item_representations_20081201/select

On Dec 4, 2008, at 3:48 PM, Ryan McKinley wrote:


http://doom:8983/solr/content_item_representations_20081201/select




Re: Is there a clean way to determine whether a core exists?

2008-12-04 Thread Chris Hostetter

: Subject: Is there a clean way to determine whether a core exists?

doesn't the CoreAdminHandler's STATUS feature make this easy?




-Hoss



Re: Is there a clean way to determine whether a core exists?

2008-12-04 Thread Noble Paul നോബിള്‍ नोब्ळ्
SOLR-880 is an issue raised for the same

On Fri, Dec 5, 2008 at 10:16 AM, Chris Hostetter
[EMAIL PROTECTED] wrote:

 : Subject: Is there a clean way to determine whether a core exists?

 doesn't the CoreAdminHandler's STATUS feature make this easy?




 -Hoss





-- 
--Noble Paul


Re: Is there a clean way to determine whether a core exists?

2008-12-04 Thread Ryan McKinley


On Dec 4, 2008, at 3:57 PM, Dean Thompson wrote:


Thanks for the quick response, Ryan!

Actually, my admin/ping call gives me a 404 if the core doesn't  
exist, which seemed reasonable.  I get the 500 if the core *did*  
exist.


aaah -- check what ping query you have configured and make sure that  
is a valid query.  If you use the example one and then change your  
schema it may be referencing fields that don't exist and give you the  
500






Thanks for the suggestion of using the select URL, but that gives me:

java.lang.NullPointerException
at org.apache.solr.common.util.StrUtils.splitSmart(StrUtils.java:37)



This is a really stupid error we need to fix -- it should actually  
say: missing required parameter q

https://issues.apache.org/jira/browse/SOLR-435


ryan


Re: Is there a clean way to determine whether a core exists?

2008-12-04 Thread Ryan McKinley

yes:
http://localhost:8983/solr/admin/cores?action=STATUS

will give you a list of running cores.  However that is not easy to  
check with a simple status != 404


see:
http://wiki.apache.org/solr/CoreAdmin


On Dec 4, 2008, at 11:46 PM, Chris Hostetter wrote:



: Subject: Is there a clean way to determine whether a core exists?

doesn't the CoreAdminHandler's STATUS feature make this easy?




-Hoss