Mailing List Archive

Fwd: svn commit: r702993 - /lucene/solr/trunk/src/webapp/src/org/apache/solr/servlet/DirectSolrConnection.java
Ryan's commit reminded me of DirectSolrConnection - this looks like an
even easier thing to plug into solr-(j)ruby than EmbeddedSolrServer.
I'll take a stab at that soon. We still should support SolrServer and
what it offers, but DirectSolrConnection will make things more easily
transparent at first.

Erik


Begin forwarded message:

> From: ryan@apache.org
> Date: October 8, 2008 5:23:21 PM EDT
> To: solr-commits@lucene.apache.org
> Subject: svn commit: r702993 - /lucene/solr/trunk/src/webapp/src/org/
> apache/solr/servlet/DirectSolrConnection.java
> Reply-To: solr-dev@lucene.apache.org
>
> Author: ryan
> Date: Wed Oct 8 14:23:21 2008
> New Revision: 702993
>
> URL: http://svn.apache.org/viewvc?rev=702993&view=rev
> Log:
> SOLR-721 -- DirectSolrConnection now uses CoreContainers
>
> Modified:
> lucene/solr/trunk/src/webapp/src/org/apache/solr/servlet/
> DirectSolrConnection.java
>
> Modified: lucene/solr/trunk/src/webapp/src/org/apache/solr/servlet/
> DirectSolrConnection.java
> URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/webapp/src/org/apache/solr/servlet/DirectSolrConnection.java?rev=702993&r1=702992&r2=702993&view=diff
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- lucene/solr/trunk/src/webapp/src/org/apache/solr/servlet/
> DirectSolrConnection.java (original)
> +++ lucene/solr/trunk/src/webapp/src/org/apache/solr/servlet/
> DirectSolrConnection.java Wed Oct 8 14:23:21 2008
> @@ -29,8 +29,11 @@
> import org.apache.solr.common.params.SolrParams;
> import org.apache.solr.common.util.ContentStream;
> import org.apache.solr.common.util.ContentStreamBase;
> +import org.apache.solr.core.CoreContainer;
> +import org.apache.solr.core.CoreDescriptor;
> import org.apache.solr.core.SolrConfig;
> import org.apache.solr.core.SolrCore;
> +import org.apache.solr.core.SolrResourceLoader;
> import org.apache.solr.request.QueryResponseWriter;
> import org.apache.solr.request.SolrQueryRequest;
> import org.apache.solr.request.SolrQueryResponse;
> @@ -101,16 +104,19 @@
> }
> }
>
> - // Initialize SolrConfig
> - SolrConfig config = null;
> + if( instanceDir == null ) {
> + instanceDir = SolrResourceLoader.locateInstanceDir();
> + }
> +
> + // Initialize
> try {
> - config = new SolrConfig(instanceDir,
> SolrConfig.DEFAULT_CONF_FILE, null);
> - instanceDir = config.getResourceLoader().getInstanceDir();
> -
> - // If the Data directory is specified, initialize SolrCore
> directly
> - IndexSchema schema = new IndexSchema(config, instanceDir+"/
> conf/schema.xml", null);
> - core = new SolrCore( null, dataDir, config, schema, null );
> - parser = new SolrRequestParsers( config );
> + CoreContainer cores = new CoreContainer(new
> SolrResourceLoader(instanceDir));
> + SolrConfig solrConfig = new SolrConfig(instanceDir,
> SolrConfig.DEFAULT_CONF_FILE, null);
> + CoreDescriptor dcore = new CoreDescriptor(cores, "",
> solrConfig.getResourceLoader().getInstanceDir());
> + IndexSchema indexSchema = new IndexSchema(solrConfig,
> instanceDir+"/conf/schema.xml", null);
> + core = new SolrCore( null, dataDir, solrConfig, indexSchema,
> dcore);
> + cores.register("", core, false);
> + parser = new SolrRequestParsers( solrConfig );
> }
> catch (Exception ee) {
> throw new RuntimeException(ee);
>