I had to hardcode the path in solrconfig.xml from this:
${solr.install.dir:}
to this:
/Users/carlroberts/dev/solr-4.10.3/
to avoid the classloader warnings, but I still get the same error. I am
not sure where the ${solr.install.dir:} value gets pulled from but
apparently that is not working. Here is the new output:
[main] INFO org.apache.solr.core.SolrResourceLoader - new
SolrResourceLoader for directory: '/Users/carlroberts/dev/solr-4.10.3/'
[main] INFO org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/lib/commons-logging-1.2.jar' to
classloader
[main] INFO org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/lib/servlet-api.jar' to classloader
[main] INFO org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/lib/slf4j-simple-1.7.5.jar' to
classloader
[main] INFO org.apache.solr.core.ConfigSolr - Loading container
configuration from /Users/carlroberts/dev/solr-4.10.3/solr.xml
[main] INFO org.apache.solr.core.CoreContainer - New CoreContainer
1023143764
[main] INFO org.apache.solr.core.CoreContainer - Loading cores into
CoreContainer [instanceDir=/Users/carlroberts/dev/solr-4.10.3/]
db
/Users/carlroberts/dev/solr-4.10.3/
[main] INFO org.apache.solr.handler.component.HttpShardHandlerFactory -
Setting socketTimeout to: 0
[main] INFO org.apache.solr.handler.component.HttpShardHandlerFactory -
Setting urlScheme to: null
[main] INFO org.apache.solr.handler.component.HttpShardHandlerFactory -
Setting connTimeout to: 0
[main] INFO org.apache.solr.handler.component.HttpShardHandlerFactory -
Setting maxConnectionsPerHost to: 20
[main] INFO org.apache.solr.handler.component.HttpShardHandlerFactory -
Setting corePoolSize to: 0
[main] INFO org.apache.solr.handler.component.HttpShardHandlerFactory -
Setting maximumPoolSize to: 2147483647
[main] INFO org.apache.solr.handler.component.HttpShardHandlerFactory -
Setting maxThreadIdleTime to: 5
[main] INFO org.apache.solr.handler.component.HttpShardHandlerFactory -
Setting sizeOfQueue to: -1
[main] INFO org.apache.solr.handler.component.HttpShardHandlerFactory -
Setting fairnessPolicy to: false
[main] INFO org.apache.solr.update.UpdateShardHandler - Creating
UpdateShardHandler HTTP client with params:
socketTimeout=0&connTimeout=0&retry=false
[main] INFO org.apache.solr.logging.LogWatcher - SLF4J impl is
org.slf4j.impl.SimpleLoggerFactory
[main] INFO org.apache.solr.logging.LogWatcher - No LogWatcher configured
[main] INFO org.apache.solr.core.CoreContainer - Host Name: null
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - new SolrResourceLoader for
directory: '/Users/carlroberts/dev/solr-4.10.3/db/'
[coreLoadExecutor-5-thread-1] INFO org.apache.solr.core.SolrConfig -
Adding specified lib dirs to ClassLoader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/extraction/lib/apache-mime4j-core-0.7.2.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/extraction/lib/apache-mime4j-dom-0.7.2.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/extraction/lib/aspectjrt-1.6.11.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/extraction/lib/bcmail-jdk15-1.45.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/extraction/lib/bcprov-jdk15-1.45.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/extraction/lib/boilerpipe-1.1.0.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/extraction/lib/commons-compress-1.7.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/extraction/lib/dom4j-1.6.1.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/extraction/lib/fontbox-1.8.4.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/extraction/lib/icu4j-53.1.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/extraction/lib/isoparser-1.0-RC-1.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/extraction/lib/jdom-1.0.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/extraction/lib/jempbox-1.8.4.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/extraction/lib/jhighlight-1.0.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/extraction/lib/juniversalchardet-1.0.3.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/extraction/lib/metadata-extractor-2.6.2.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/extraction/lib/pdfbox-1.8.4.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/extraction/lib/poi-3.10.1.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/extraction/lib/poi-ooxml-3.10.1.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/extraction/lib/poi-ooxml-schemas-3.10.1.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/extraction/lib/poi-scratchpad-3.10.1.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/extraction/lib/rome-0.9.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/extraction/lib/tagsoup-1.2.1.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/extraction/lib/tika-core-1.5.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/extraction/lib/tika-parsers-1.5.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/extraction/lib/tika-xmp-1.5.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/extraction/lib/vorbis-java-core-0.1.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/extraction/lib/vorbis-java-tika-0.1.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/extraction/lib/xercesImpl-2.9.1.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/extraction/lib/xmlbeans-2.6.0.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/extraction/lib/xmpcore-5.1.2.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/extraction/lib/xz-1.4.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/dist/solr-cell-4.10.3.jar' to
classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/clustering/lib/attributes-binder-1.2.1.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/clustering/lib/carrot2-mini-3.9.0.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/clustering/lib/hppc-0.5.2.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/clustering/lib/jackson-core-asl-1.9.13.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/clustering/lib/jackson-mapper-asl-1.9.13.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/clustering/lib/mahout-collections-1.0.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/clustering/lib/mahout-math-0.6.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/clustering/lib/simple-xml-2.7.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/dist/solr-clustering-4.10.3.jar' to
classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/langid/lib/jsonic-1.2.7.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/langid/lib/langdetect-1.1-20120112.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/dist/solr-langid-4.10.3.jar' to
classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/velocity/lib/commons-beanutils-1.8.3.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/velocity/lib/commons-collections-3.2.1.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/velocity/lib/velocity-1.7.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/contrib/velocity/lib/velocity-tools-2.0.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/dist/solr-velocity-4.10.3.jar'
to classloader
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.update.SolrIndexConfig - IndexWriter infoStream solr
logging is enabled
[coreLoadExecutor-5-thread-1] INFO org.apache.solr.core.SolrConfig -
Using Lucene MatchVersion: 4.10.3
[coreLoadExecutor-5-thread-1] INFO org.apache.solr.core.Config - Loaded
SolrConfig: solrconfig.xml
[coreLoadExecutor-5-thread-1] INFO org.apache.solr.schema.IndexSchema -
Reading Solr Schema from
/Users/carlroberts/dev/solr-4.10.3/db/conf/schema.xml
[coreLoadExecutor-5-thread-1] INFO org.apache.solr.schema.IndexSchema -
[db] Schema name=example
false
{}
[]
/Users/carlroberts/dev/solr-4.10.3/
Exception in thread "main" org.apache.solr.common.SolrException: No such
core: db
at
org.apache.solr.client.solrj.embedded.EmbeddedSolrServer.request(EmbeddedSolrServer.java:112)
at
org.apache.solr.client.solrj.request.AbstractUpdateRequest.process(AbstractUpdateRequest.java:124)
at org.apache.solr.client.solrj.SolrServer.add(SolrServer.java:68)
at org.apache.solr.client.solrj.SolrServer.add(SolrServer.java:54)
at solr.Test.main(Test.java:40)
On 1/21/15, 12:01 PM, Carl Roberts wrote:
OK - I figured out the logging. Here is the logging output plus the
console output and the stack trace:
main] INFO org.apache.solr.core.SolrResourceLoader - new
SolrResourceLoader for directory: '/Users/carlroberts/dev/solr-4.10.3/'
[main] INFO org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/lib/commons-logging-1.2.jar'
to classloader
[main] INFO org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/lib/servlet-api.jar' to
classloader
[main] INFO org.apache.solr.core.SolrResourceLoader - Adding
'file:/Users/carlroberts/dev/solr-4.10.3/lib/slf4j-simple-1.7.5.jar'
to classloader
[main] INFO org.apache.solr.core.ConfigSolr - Loading container
configuration from /Users/carlroberts/dev/solr-4.10.3/solr.xml
[main] INFO org.apache.solr.core.CoreContainer - New CoreContainer
2050551931
db
/Users/carlroberts/dev/solr-4.10.3/[main] INFO
org.apache.solr.core.CoreContainer - Loading cores into CoreContainer
[instanceDir=/Users/carlroberts/dev/solr-4.10.3/]
[main] INFO org.apache.solr.handler.component.HttpShardHandlerFactory
- Setting socketTimeout to: 0
[main] INFO org.apache.solr.handler.component.HttpShardHandlerFactory
- Setting urlScheme to: null
[main] INFO org.apache.solr.handler.component.HttpShardHandlerFactory
- Setting connTimeout to: 0
[main] INFO org.apache.solr.handler.component.HttpShardHandlerFactory
- Setting maxConnectionsPerHost to: 20
[main] INFO org.apache.solr.handler.component.HttpShardHandlerFactory
- Setting corePoolSize to: 0
[main] INFO org.apache.solr.handler.component.HttpShardHandlerFactory
- Setting maximumPoolSize to: 2147483647
[main] INFO org.apache.solr.handler.component.HttpShardHandlerFactory
- Setting maxThreadIdleTime to: 5
[main] INFO org.apache.solr.handler.component.HttpShardHandlerFactory
- Setting sizeOfQueue to: -1
[main] INFO org.apache.solr.handler.component.HttpShardHandlerFactory
- Setting fairnessPolicy to: false
[main] INFO org.apache.solr.update.UpdateShardHandler - Creating
UpdateShardHandler HTTP client with params:
socketTimeout=0&connTimeout=0&retry=false
[main] INFO org.apache.solr.logging.LogWatcher - SLF4J impl is
org.slf4j.impl.SimpleLoggerFactory
[main] INFO org.apache.solr.logging.LogWatcher - No LogWatcher configured
[main] INFO org.apache.solr.core.CoreContainer - Host Name: null
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.core.SolrResourceLoader - new SolrResourceLoader for
directory: '/Users/carlroberts/dev/solr-4.10.3/db/'
[coreLoadExecutor-5-thread-1] INFO org.apache.solr.core.SolrConfig -
Adding specified lib dirs to ClassLoader
[coreLoadExecutor-5-thread-1] WARN
org.apache.solr.core.SolrResourceLoader - Can't find (or read)
directory to add to classloader: ../../../contrib/extraction/lib
(resolved as:
/Users/carlroberts/dev/solr-4.10.3/db/../../../contrib/extraction/lib).
[coreLoadExecutor-5-thread-1] WARN
org.apache.solr.core.SolrResourceLoader - Can't find (or read)
directory to add to classloader: ../../../dist/ (resolved as:
/Users/carlroberts/dev/solr-4.10.3/db/../../../dist).
[coreLoadExecutor-5-thread-1] WARN
org.apache.solr.core.SolrResourceLoader - Can't find (or read)
directory to add to classloader: ../../../contrib/clustering/lib/
(resolved as:
/Users/carlroberts/dev/solr-4.10.3/db/../../../contrib/clustering/lib).
[coreLoadExecutor-5-thread-1] WARN
org.apache.solr.core.SolrResourceLoader - Can't find (or read)
directory to add to classloader: ../../../dist/ (resolved as:
/Users/carlroberts/dev/solr-4.10.3/db/../../../dist).
[coreLoadExecutor-5-thread-1] WARN
org.apache.solr.core.SolrResourceLoader - Can't find (or read)
directory to add to classloader: ../../../contrib/langid/lib/
(resolved as:
/Users/carlroberts/dev/solr-4.10.3/db/../../../contrib/langid/lib).
[coreLoadExecutor-5-thread-1] WARN
org.apache.solr.core.SolrResourceLoader - Can't find (or read)
directory to add to classloader: ../../../dist/ (resolved as:
/Users/carlroberts/dev/solr-4.10.3/db/../../../dist).
[coreLoadExecutor-5-thread-1] WARN
org.apache.solr.core.SolrResourceLoader - Can't find (or read)
directory to add to classloader: ../../../contrib/velocity/lib
(resolved as:
/Users/carlroberts/dev/solr-4.10.3/db/../../../contrib/velocity/lib).
[coreLoadExecutor-5-thread-1] WARN
org.apache.solr.core.SolrResourceLoader - Can't find (or read)
directory to add to classloader: ../../../dist/ (resolved as:
/Users/carlroberts/dev/solr-4.10.3/db/../../../dist).
[coreLoadExecutor-5-thread-1] INFO
org.apache.solr.update.SolrIndexConfig - IndexWriter infoStream solr
logging is enabled
[coreLoadExecutor-5-thread-1] INFO org.apache.solr.core.SolrConfig -
Using Lucene MatchVersion: 4.10.3
[coreLoadExecutor-5-thread-1] INFO org.apache.solr.core.Config -
Loaded SolrConfig: solrconfig.xml
[coreLoadExecutor-5-thread-1] INFO org.apache.solr.schema.IndexSchema
- Reading Solr Schema from
/Users/carlroberts/dev/solr-4.10.3/db/conf/schema.xml
[coreLoadExecutor-5-thread-1] INFO org.apache.solr.schema.IndexSchema
- [db] Schema name=example
false
{}
[]
/Users/carlroberts/dev/solr-4.10.3/
Exception in thread "main" org.apache.solr.common.SolrException: No
such core: db
at
org.apache.solr.client.solrj.embedded.EmbeddedSolrServer.request(EmbeddedSolrServer.java:112)
at
org.apache.solr.client.solrj.request.AbstractUpdateRequest.process(AbstractUpdateRequest.java:124)
at org.apache.solr.client.solrj.SolrServer.add(SolrServer.java:68)
at org.apache.solr.client.solrj.SolrServer.add(SolrServer.java:54)
at solr.Test.main(Test.java:40)
On 1/21/15, 11:50 AM, Alan Woodward wrote:
That certainly looks like it ought to work. Is there log output that
you could show us as well?
Alan Woodward
www.flax.co.uk
On 21 Jan 2015, at 16:09, Carl Roberts wrote:
Hi,
I have downloaded the code and documentation for Solr version 4.10.3.
I am trying to follow SolrJ Wiki guide and I am running into
errors. The latest error is this one:
Exception in thread "main" org.apache.solr.common.SolrException: No
such core: db
at
org.apache.solr.client.solrj.embedded.EmbeddedSolrServer.request(EmbeddedSolrServer.java:112)
at
org.apache.solr.client.solrj.request.AbstractUpdateRequest.process(AbstractUpdateRequest.java:124)
at org.apache.solr.client.solrj.SolrServer.add(SolrServer.java:68)
at org.apache.solr.client.solrj.SolrServer.add(SolrServer.java:54)
at solr.Test.main(Test.java:39)
My code is this:
package solr;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.core.SolrCore;
public class Test {
public static void main(String [] args){
CoreContainer container = new
CoreContainer("/Users/carlroberts/dev/solr-4.10.3");
System.out.println(container.getDefaultCoreName());
System.out.println(container.getSolrHome());
container.load();
System.out.println(container.isLoaded("db"));
System.out.println(container.getCoreInitFailures());
Collection<SolrCore> cores = container.getCores();
System.out.println(cores);
EmbeddedSolrServer server = new EmbeddedSolrServer(
container, "db" );
SolrInputDocument doc1 = new SolrInputDocument();
doc1.addField( "id", "id1", 1.0f );
doc1.addField( "name", "doc1", 1.0f );
doc1.addField( "price", 10 );
SolrInputDocument doc2 = new SolrInputDocument();
doc2.addField( "id", "id2", 1.0f );
doc2.addField( "name", "doc2", 1.0f );
doc2.addField( "price", 20 );
Collection<SolrInputDocument> docs = new
ArrayList<SolrInputDocument>();
docs.add( doc1 );
docs.add( doc2 );
try{
server.add( docs );
server.commit();
server.deleteByQuery( "*:*" );
}catch(IOException e){
e.printStackTrace();
}catch(SolrServerException e){
e.printStackTrace();
}
}
}
My solr.xml file is this:
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!--
This is an example of a simple "solr.xml" file for configuring
one or
more Solr Cores, as well as allowing Cores to be added, removed, and
reloaded via HTTP requests.
More information about options available in this configuration file,
and Solr Core administration can be found online:
http://wiki.apache.org/solr/CoreAdmin
-->
<solr>
<cores adminPath="/admin/cores" defaultCoreName="db">
<core default="true" instanceDir="db/" name="db"/>
</cores>
</solr>
And my db/conf directory was copied from
example/solr/collection/conf directory and it contains the
solrconfig.xml file and schema.xml file.
I have noticed that the documentation that shows how to use the
EmbeddedSolarServer is outdated as it indicates I should use
CoreContainer.Initializer class which doesn't exist, and
container.load(path, file) which also doesn't exist.
At this point I have no idea why I am getting the No such core error
and I have googled it and there seems to be tons of threads showing
this error but for different reasons, and I have tried all the
suggested resolutions and get nowhere with this.
Can you please help?
Regards,
Joe