Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Solr - _version_ field must exist in schema and be searchable

Tags:

solr

lucene

I am pretty new to Solr and getting error on setting up my first example core. I am trying to add new core under admin dashboard but I am receving error about version field.

Is there any workaround for this?

Background:

  • OS: Windows
  • Solr Folder: C:\solr-6.0.0
  • Core Admin Url: http://localhost:8984/solr/#/~cores
  • Folder Created For new_core: C:\solr-6.0.0\server\solr\new_core
  • Error: Error CREATEing SolrCore 'new_core': Unable to create core [new_core] Caused by: _version_ field must exist in schema and be searchable (indexed or docValues) and retrievable(stored or docValues) and not multiValued (_version_ does not exist)

Schema Xml:

<?xml version="1.0" encoding="UTF-8" ?>

<!--
For fts-solr:

This is the Solr schema file, place it into solr/conf/schema.xml. You may
want to modify the tokenizers and filters.
-->
<schema name="dovecot" version="1.1">
  <types>
    <!-- IMAP has 32bit unsigned ints but java ints are signed, so use longs -->
    <fieldType name="string" class="solr.StrField" omitNorms="true"/>            
    <fieldType name="boolean" class="solr.BoolField" omitNorms="true"/>
    <fieldType name="long" class="solr.LongField" omitNorms="true"/>

    <fieldType name="text" class="solr.TextField" positionIncrementGap="100">
      <analyzer type="index">
        <tokenizer class="solr.WhitespaceTokenizerFactory"/>      
        <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="1" catenateNumbers="1" catenateAll="0"/>
        <filter class="solr.LowerCaseFilterFactory"/>        
        <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
      </analyzer>
      <analyzer type="query">
        <tokenizer class="solr.WhitespaceTokenizerFactory"/>                
        <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="0" catenateNumbers="0" catenateAll="0"/>
        <filter class="solr.LowerCaseFilterFactory"/>        
        <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
      </analyzer>
    </fieldType>
 </types>


 <fields>
   <field name="_version_" type="long" indexed="true" stored="true" multiValued="false"/>
   <field name="id" type="string" indexed="true" stored="true" required="true" />       
   <field name="box" type="string" indexed="true" stored="true" required="true" /> 
   <field name="user" type="string" indexed="true" stored="true" required="true" /> 
   <field name="ns" type="string" indexed="true" stored="true" required="false" /> 
   <field name="last_uid" type="boolean" indexed="true" stored="false" /> 
   <field name="hdr" type="text" indexed="true" stored="false" /> 
   <field name="body" type="text" indexed="true" stored="false" /> 
 </fields>

 <uniqueKey>id</uniqueKey>
 <defaultSearchField>body</defaultSearchField>
 <solrQueryParser defaultOperator="AND" />
</schema>

Screen Shot:

enter image description here

like image 214
Teoman shipahi Avatar asked Apr 29 '16 15:04

Teoman shipahi


2 Answers

Your schema comes from an example for a very old version of Solr. You need to either use the version of Solr that is recommended with that version of Dovecot or adjust it to the new requirements.

Compare your schema to the basic example schema that comes with Solr 6 itself. There is quite a number of differences:

  1. Schema version is now up to 1.6 (yours is 1.1)
  2. types and fields outer tags are no longer needed and you just list types/fields in any order you want
  3. defaultSearchField and solrQueryParser are both considered not recommended anymore and should be moved into the request handler configuration in the solrconfig.xml

Your field name should also be _version_ (with underscores). The advice you got about removing those is due to StackOverflow formatting (converting underscores to italic)...

Are you getting an error after the restart? Or nothing at all. With new Solr, the cores need to be under the solr home (yours seems to be) and needs to contain core.properties file. If you got an error during the creation, that file may not have been created and restarting the server may not notice the collection/core anyway. Just make sure you are repeating the same steps (e.g. creating/registering core) every time as you are testing your changes.

like image 177
Alexandre Rafalovitch Avatar answered Oct 18 '22 23:10

Alexandre Rafalovitch


I would like to add a solution that helped me here; Solr makes a copy of your config file and puts it in [core name]/conf/ folder called managed-schema. Make sure to remove this file after editing your schema file, or else your changes will not be detected, because Solr seem to use the copy rather than the original schema.xml file.

like image 6
mufasa Avatar answered Oct 19 '22 00:10

mufasa