org.apache.solr.common.SolrException: No such core: core0

删除掉E:/Java Projects/fulltextsearch/WebRoot/WEB-INF/solr/multicore/data0/index下所有索引相关的文件之后,再次运行程序报:

2011-5-20 15:17:01 org.apache.solr.common.SolrException log
严重: java.lang.RuntimeException: java.io.FileNotFoundException: no segments* file found in org.apache.lucene.store.SimpleFSDirectory@E:/Java Projects/fulltextsearch/WebRoot/WEB-INF/solr/multicore/data0/index: files:
 at org.apache.solr.core.SolrCore.getSearcher(SolrCore.java:1068)
 at org.apache.solr.core.SolrCore.<init>(SolrCore.java:579)
 at org.apache.solr.core.CoreContainer.create(CoreContainer.java:428)
 at org.apache.solr.core.CoreContainer.load(CoreContainer.java:278)
 at org.apache.solr.core.CoreContainer$Initializer.initialize(CoreContainer.java:117)
 at org.fts.solrj.SolrjTest.<clinit>(SolrjTest.java:22)
Caused by: java.io.FileNotFoundException: no segments* file found in org.apache.lucene.store.SimpleFSDirectory@E:/Java Projects/fulltextsearch/WebRoot/WEB-INF/solr/multicore/data0/index: files:
 at org.apache.lucene.index.SegmentInfos$FindSegmentsFile.run(SegmentInfos.java:634)
 at org.apache.lucene.index.DirectoryReader.open(DirectoryReader.java:69)
 at org.apache.lucene.index.IndexReader.open(IndexReader.java:476)
 at org.apache.lucene.index.IndexReader.open(IndexReader.java:403)
 at org.apache.solr.core.StandardIndexReaderFactory.newReader(StandardIndexReaderFactory.java:38)
 at org.apache.solr.core.SolrCore.getSearcher(SolrCore.java:1057)
 ... 5 more


2011-5-20 15:17:01 org.apache.solr.core.SolrResourceLoader <init>
信息: Solr home set to 'E:/Java Projects/fulltextsearch/WebRoot/WEB-INF/solr/multicore/./'
2011-5-20 15:17:01 org.apache.solr.core.SolrCore finalize
严重: REFCOUNT ERROR: unreferenced org.apache.solr.core.SolrCore@12d263f (core0) has a reference count of 1

 

Exception in thread "main" org.apache.solr.common.SolrException: No such core: core0
 at org.apache.solr.client.solrj.embedded.EmbeddedSolrServer.request(EmbeddedSolrServer.java:104)
 at org.apache.solr.client.solrj.request.AbstractUpdateRequest.process(AbstractUpdateRequest.java:105)
 at org.apache.solr.client.solrj.SolrServer.add(SolrServer.java:49)

程序代码如下:

try { //MultiCore System.setProperty("solr.solr.home",getSoleHome()); initializer = new CoreContainer.Initializer(); coreContainer = initializer.initialize(); List<String> ls = (List<String>)coreContainer.getCoreNames(); for(String s : ls){ System.out.println(ls.size()+"-"+s); } server = new EmbeddedSolrServer(coreContainer, "core0"); } catch (Exception e) { e.printStackTrace(); }

solr.xml文件内容如下:

<cores adminPath="/admin/cores"> <core name="core0" instanceDir="." schema="schema0.xml" config="solrconfig.xml" dataDir="./data0"/> <core name="core1" instanceDir="." schema="schema1.xml" config="solrconfig.xml" dataDir="./data1"/> </cores>

 

  在solr.xml文件明明是配置了core0和core1,可通过调试代码发现coreContainer.getCoreNames()获取到的Core数为0个。真是百思不得其解,网上google了一下也没找到解决的办法。

 

摸着石头过河,解决方法如下:

最后试着删掉E:/Java Projects/fulltextsearch/WebRoot/WEB-INF/solr/multicore/data0/index下的index目录,再次运行程序问题不在出现,同时在data0目录下重新生成了一个index目录,并且在index目录下生成了两个文件:segments_1、segments.gen

 

你可能感兴趣的:(thread,exception,schema,File,Solr,reference)