lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jfmn...@free.fr
Subject Re: SolrException: No such core
Date Wed, 02 Jun 2010 15:14:44 GMT
Solr is used to manage lists of indexes.
We have a database containing documents of different types.
Each document type is defined by a list of properties and we want to associate some of these
properties with lists of indexes to help users during query.

For example:
The property contains a text field "desc" may be associated with a field Solr "desc_en_items.

"Desc_en_items" is a dynamic field solr:
  <dynamicField name="*_en_items" type="en_items" indexed="true" stored="false" multiValued="true"/>

And so on for each property associated with a field Solr.

Each Solr document contains an identifier (stored and indexed) Solr and dynamic fields. (only
indexed)

When adding a document in our database, if needed, we dynamically generate the document and
add it to solr. When a document is deleted from our database we suppress systematically the
solr document "deleteById" (the document can not exist in solr).

There is only one core (Core0) and the server is embedded.

We use a derived lucli/LuceneMethods.java to browse index.
 
It seems to me, without being sure, that the problem comes when no list is set (solr is started
but contains no records) in a few days of operation. We have a database with lists parameterized
works for several months without problem.

Here the wrappers to use ...solrj.SolrServer
[code]
public class SolrCoreServer
{
   private static Logger log = LoggerFactory.getLogger(SolrCoreServer.class);
	
   private SolrServer server=null;
   
   public SolrCoreServer(CoreContainer container, String coreName)
   {
      server = new EmbeddedSolrServer( container, coreName );
   }

   protected SolrServer getSolrServer(){
      return server;
   }
   
   public void cleanup() throws SolrServerException, IOException {
	   log.debug("cleanup()");
	   UpdateResponse rsp = server.deleteByQuery( "*:*" );
	   log.debug("cleanup():" + rsp.getStatus());
	   if (rsp.getStatus() != 0)
		   throw new SolrServerException("cleanup() failed status=" + rsp.getStatus());
   }
 
   public void add(SolrInputDocument doc) throws SolrServerException, IOException{
	   log.debug("add(" + doc + ")");
	   UpdateResponse rsp = server.add(doc);
	   log.debug("add():" + rsp.getStatus());
	   if (rsp.getStatus() != 0)
		   throw new SolrServerException("add() failed status=" + rsp.getStatus());
    }
   
   public void add(Collection<SolrInputDocument> docs) throws SolrServerException, IOException{
	   log.debug("add(" + docs + ")");
	   UpdateResponse rsp = server.add(docs);
	   log.debug("add():" + rsp.getStatus());
	   if (rsp.getStatus() != 0)
		   throw new SolrServerException("add() failed status=" + rsp.getStatus());
   }
   
   public void deleteById(String docId) throws SolrServerException, IOException{
	   log.debug("deleteById(" + docId + ")");
	   UpdateResponse rsp = server.deleteById(docId);
	   log.debug("deleteById():" + rsp.getStatus());
	   if (rsp.getStatus() != 0)
		   throw new SolrServerException("deleteById() failed status=" + rsp.getStatus());
    }
      
   public void commit() throws SolrServerException, IOException {
	   log.debug("commit()");
	   UpdateResponse rsp = server.commit();
	   log.debug("commit():" + rsp.getStatus());
	   if (rsp.getStatus() != 0)
		   throw new SolrServerException("commit() failed status=" + rsp.getStatus());
   }
      
   public void addAndCommit(Collection<SolrInputDocument> docs) throws SolrServerException,
IOException{
	  log.debug("addAndCommit(" + docs + ")");
      UpdateRequest req = new UpdateRequest(); 
      req.setAction( UpdateRequest.ACTION.COMMIT, false, false );
      req.add( docs );
      UpdateResponse rsp = req.process( server );  
      log.debug("addAndCommit():" + rsp.getStatus());
	  if (rsp.getStatus() != 0)
		   throw new SolrServerException("addAndCommit() failed status=" + rsp.getStatus());
   }
      
   public QueryResponse query( SolrQuery query ) throws SolrServerException{
	  log.debug("query(" + query + ")");
      QueryResponse qr =  server.query( query );
      log.debug("query():" + qr.getStatus());
	  return qr;
   }

   public QueryResponse query( String queryString, String sortField, SolrQuery.ORDER order,
Integer maxRows ) throws SolrServerException{
	  log.debug("query(" + queryString + ")");
      SolrQuery query = new SolrQuery();
      query.setQuery( queryString );
      query.addSortField( sortField, order );
      query.setRows(maxRows);
      QueryResponse qr = server.query( query );
      log.debug("query():" + qr.getStatus());
	  return qr;
   }

}
[/code]

the schema
[code]
<?xml version="1.0" ?>
<!--
 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.
-->


<schema name="schema core " version="1.1">
  <types>
    <fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>
    <fieldType name="boolean" class="solr.BoolField" sortMissingLast="true" omitNorms="true"/>
    <fieldType name="integer" class="solr.IntField" omitNorms="true"/>
    <fieldType name="long" class="solr.LongField" omitNorms="true"/>
    <fieldType name="float" class="solr.FloatField" omitNorms="true"/>
    <fieldType name="double" class="solr.DoubleField" omitNorms="true"/>
    <fieldType name="sint" class="solr.SortableIntField" sortMissingLast="true" omitNorms="true"/>
    <fieldType name="slong" class="solr.SortableLongField" sortMissingLast="true" omitNorms="true"/>
    <fieldType name="sfloat" class="solr.SortableFloatField" sortMissingLast="true" omitNorms="true"/>
    <fieldType name="sdouble" class="solr.SortableDoubleField" sortMissingLast="true" omitNorms="true"/>
    <fieldType name="date" class="solr.DateField" sortMissingLast="true" omitNorms="true"/>
    <fieldType name="text_ws" class="solr.TextField" positionIncrementGap="100">
      <analyzer>
        <tokenizer class="solr.WhitespaceTokenizerFactory"/>
      </analyzer>
    </fieldType>
    <fieldType name="text_hl" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>
    <fieldtype name="ignored" stored="false" indexed="false" class="solr.StrField" />



   <fieldType name="fr_items" class="solr.TextField">
      <analyzer>
        <tokenizer class="solr.StandardTokenizerFactory"/>
        <filter class="solr.StandardFilterFactory"/>
	<filter class="solr.ISOLatin1AccentFilterFactory"/>
	<filter class="solr.LowerCaseFilterFactory"/>
	<filter class="solr.StopFilterFactory" words="fr-stopwords.txt" ignoreCase="true"/>
      </analyzer>
   </fieldType>

   <fieldType name="en_items" class="solr.TextField">
      <analyzer>
        <tokenizer class="solr.StandardTokenizerFactory"/>
        <filter class="solr.StandardFilterFactory"/>
	<filter class="solr.ISOLatin1AccentFilterFactory"/>
	<filter class="solr.LowerCaseFilterFactory"/>
	<filter class="solr.StopFilterFactory" words="en-stopwords.txt" ignoreCase="true"/>
      </analyzer>
   </fieldType>

   <fieldType name="es_items" class="solr.TextField">
      <analyzer>
        <tokenizer class="solr.StandardTokenizerFactory"/>
        <filter class="solr.StandardFilterFactory"/>
	<filter class="solr.ISOLatin1AccentFilterFactory"/>
	<filter class="solr.LowerCaseFilterFactory"/>
	<filter class="solr.StopFilterFactory" words="es-stopwords.txt" ignoreCase="true"/>
      </analyzer>
   </fieldType>

  </types>

 <fields>   
  <field name="id"       type="string"    indexed="true"  stored="true"  multiValued="false"
required="true"/>

  <dynamicField name="*_int"  type="sint"  indexed="true"  stored="false"  multiValued="true"/>
  <dynamicField name="*_bool"  type="boolean"  indexed="true"  stored="false" multiValued="true"/>
  <dynamicField name="*_long"  type="slong"  indexed="true"  stored="false" multiValued="true"/>
  <dynamicField name="*_float"  type="sfloat"  indexed="true"  stored="false" multiValued="true"/>
  <dynamicField name="*_double"  type="sdouble"  indexed="true"  stored="false" multiValued="true"/>
  <dynamicField name="*_date"  type="date"  indexed="true"  stored="false" multiValued="true"/>
  <dynamicField name="*_fr_items"  type="fr_items"  indexed="true"  stored="false" multiValued="true"/>
  <dynamicField name="*_en_items"  type="en_items"  indexed="true"  stored="false" multiValued="true"/>
  <dynamicField name="*_es_items"  type="es_items"  indexed="true"  stored="false" multiValued="true"/>
  <dynamicField name="*_string"  type="string"  indexed="true"  stored="false" multiValued="true"/>
  <dynamicField name="*_hl"  type="text_hl"  indexed="true"  stored="false" multiValued="true"/>
 </fields>

 <!-- field to use to determine and enforce document uniqueness. -->
 <uniqueKey>id</uniqueKey>

 <!-- field for the QueryParser to use when an explicit fieldname is absent -->
 <defaultSearchField>id</defaultSearchField>

 <!-- SolrQueryParser configuration: defaultOperator="AND|OR" -->
 <solrQueryParser defaultOperator="OR"/>
</schema>
[/code]

SolrConfig.xml
[code]
<?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 a stripped down config file used for a simple example...  
 It is *not* a good example to work from. 
-->
<config>
  <mainIndex>
    <maxFieldLength>100000</maxFieldLength> 
  </mainIndex>

  <updateHandler class="solr.DirectUpdateHandler2" />

  <requestDispatcher handleSelect="true" >
    <requestParsers enableRemoteStreaming="true" multipartUploadLimitInKB="2048" />
  </requestDispatcher>
  
  <requestHandler name="standard" class="solr.StandardRequestHandler" default="true" />
  <requestHandler name="/update" class="solr.XmlUpdateRequestHandler" />
  <requestHandler name="/admin/" class="org.apache.solr.handler.admin.AdminHandlers" />
      
  <!-- config for the admin interface --> 
  <admin>
    <defaultQuery>*:*</defaultQuery>
  </admin>

  <indexDefaults>
   <lockType>native</lockType>
  </indexDefaults>
</config>
[/code]


solr.xml
[code]
<?xml version='1.0' encoding='UTF-8'?><solr persistent="true">
<cores adminPath="/admin/cores">
  <core name="core0" instanceDir="core0/"/>
</cores>
</solr>
[/code]



----- Mail Original -----
De: "Chris Hostetter" <hossman_lucene@fucit.org>
À: solr-user@lucene.apache.org
Envoyé: Mardi 1 Juin 2010 23h42:56 GMT +01:00 Amsterdam / Berlin / Berne / Rome / Stockholm
/ Vienne
Objet: Re: SolrException: No such core


You have to give us more details then that if you expect anyone to have 
a clue what might be going wrong...

* what does your code for initializing solr look like?
* what does your soler home dir look like (ie: what files are in it)
* what do all of your config files look like?
* what is the full stack trace of these exceptions, and what does your 
code look like around the lines where these stack traces indicate your 
code is interacting with solr?
* etc...

	http://wiki.apache.org/solr/UsingMailingLists


: Date: Fri, 28 May 2010 11:19:49 +0200 (CEST)
: From: jfmnews@free.fr
: Reply-To: solr-user@lucene.apache.org
: To: solr-user@lucene.apache.org
: Subject: SolrException: No such core
: 
: With embedded solr (1.3.0) sometime a SolrException happens. 
: I don't understand why : I have not been able to find a scenario. 
: 
: 
: org.apache.solr.common.SolrException: No such core: core0
: at org.apache.solr.client.solrj.embedded.EmbeddedSolrServer.request(EmbeddedSolrServer.java:112)
: at org.apache.solr.client.solrj.request.UpdateRequest.process(UpdateRequest.java:217)
: at org.apache.solr.client.solrj.SolrServer.deleteById(SolrServer.java:97)
: 
: Regards
: 
: JF
: 



-Hoss


Mime
View raw message