Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Schema configuration in solr

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 309
    Comment on it

    Schema Configuration:

     

    For performing indexing you have to create indexes first in the schema.xml file.

    This is the file which you have to configure to perform any further operations. It the contains the fields which needs to be indexed, their types , and their attributes.

    In the latest version of solr , this file will be automatically created with the name of ManagedSchema inside the /solr-5.4.1/server/solr/[collection-name]/conf folder.

    Example of schema.xml file:

    <?xml version="1.0" encoding="UTF-8" ?>
    
    <schema name="example" version="1.5">
      
     <fields>
       <field name="id" type="string" indexed="true" stored="true" required="true" />
      <field name="name" type="string" indexed="true" stored="true"/>
      <field name="address" type="text_general" indexed="true" stored="true"/>
      </fields>
    
     <uniqueKey>id</uniqueKey>
     
    
    <types>
       
    </fieldType>
    
        <fieldType name="string" class="solr.StrField" sortMissingLast="true" />
        <fieldType name="booleans" class="solr.BoolField" sortMissingLast="true"/>
        <fieldType name="int" class="solr.TrieIntField" precisionStep="0" positionIncrementGap="0"/>
        <fieldType name="float" class="solr.TrieFloatField" precisionStep="0" positionIncrementGap="0"/>
        <fieldType name="long" class="solr.TrieLongField" precisionStep="0" positionIncrementGap="0"/>
        <fieldType name="double" class="solr.TrieDoubleField" precisionStep="0" positionIncrementGap="0"/>
    
       
        <fieldType name="tint" class="solr.TrieIntField" precisionStep="8" positionIncrementGap="0"/>
        <fieldType name="tfloat" class="solr.TrieFloatField" precisionStep="8" positionIncrementGap="0"/>
        <fieldType name="tlong" class="solr.TrieLongField" precisionStep="8" positionIncrementGap="0"/>
        <fieldType name="tdouble" class="solr.TrieDoubleField" precisionStep="8" positionIncrementGap="0"/>
         <fieldType name="tdates" class="solr.TrieDateField" precisionStep="6" positionIncrementGap="0" multiValued="true"/>
          <fieldType name="tints" class="solr.TrieIntField" precisionStep="8" positionIncrementGap="0" multiValued="true"/>
        <fieldType name="tfloats" class="solr.TrieFloatField" precisionStep="8" positionIncrementGap="0" multiValued="true"/>
        <fieldType name="tlongs" class="solr.TrieLongField" precisionStep="8" positionIncrementGap="0" multiValued="true"/>
        <fieldType name="tdoubles" class="solr.TrieDoubleField" precisionStep="8" positionIncrementGap="0" multiValued="true"/>
        
      
        <fieldType name="text_general" class="solr.TextField" positionIncrementGap="100">
          <analyzer type="index">
            <tokenizer class="solr.StandardTokenizerFactory"/>
            <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/>
           
            <filter class="solr.LowerCaseFilterFactory"/>
          </analyzer>
          <analyzer type="query">
            <tokenizer class="solr.StandardTokenizerFactory"/>
            <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/>
            <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
            <filter class="solr.LowerCaseFilterFactory"/>
          </analyzer>
        </fieldType>
      
        <fieldType name="lowercase" class="solr.TextField" positionIncrementGap="100">
          <analyzer>
            <tokenizer class="solr.KeywordTokenizerFactory"/>
            <filter class="solr.LowerCaseFilterFactory" />
          </analyzer>
        </fieldType>
    
     </types>
     </schema>
    

    Within the fields tag, you need to define the fields which you want to use in your document and there is a type associated with each field which also needs to be defined in this file. e.g. there is a field type called text_general which is used in our address field. So we define all the field types within the types tag.

    The id field is mandatory and unique for each entry of the field in the document.

    We'll see how to create and index documents in the next post.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: