ToDo #576

avatar

Use a cleaner solr schema

Added by Matt Zumwalt 275 days ago.

Status:New Start:10/27/2009
Priority:Normal Due date:
Assigned to:- % Done:

0%

Category:- Spent time: -
Target version:2.0 Release: MODS, Nokogiri & better Solr
Sponsor:


Description

Use the basic starter schema that comes with solr, adding the modifications described in the Blacklight Solr Readme

From the Blacklight Readme:

 The default schema.xml file comes with some preset fields made to work with
  the example data. If you don't already have a schema.xml setup, we
  recommend using a simplified "fields" section like this:
        <fields>
                <field name="id" type="string" indexed="true" stored="true" required="true" />
                <field name="text" type="text" indexed="true" stored="false" multiValued="true"/>
                <field name="timestamp" type="date" indexed="true" stored="true" default="NOW" multiValued="false"/>
                <field name="spell" type="textSpell" indexed="true" stored="true" multiValued="true"/>
                <dynamicField name="*_i"  type="sint"    indexed="true"  stored="true"/>
                <dynamicField name="*_s"  type="string"  indexed="true"  stored="true" multiValued="true"/>
                <dynamicField name="*_l"  type="slong"   indexed="true"  stored="true"/>
                <dynamicField name="*_t"  type="text"    indexed="true"  stored="true" multiValued="true"/>
                <dynamicField name="*_b"  type="boolean" indexed="true"  stored="true"/>
                <dynamicField name="*_f"  type="sfloat"  indexed="true"  stored="true"/>
                <dynamicField name="*_d"  type="sdouble" indexed="true"  stored="true"/>
                <dynamicField name="*_dt" type="date"    indexed="true"  stored="true"/>
                <dynamicField name="random*" type="random" />
                <dynamicField name="*_facet" type="string" indexed="true" stored="true" multiValued="true" />
                <dynamicField name="*_display" type="string" indexed="false" stored="true" />
        </fields>

  Simply replace the "fields" section in the schema.xml with the block above.

  Additionally, replace all of the tags after the "fields" section, and before
  the </schema> tag with this:
        <uniqueKey>id</uniqueKey>
        <defaultSearchField>text</defaultSearchField>
        <solrQueryParser defaultOperator="OR"/>
        <copyField source="*_facet" dest="text"/>

  Now you have a basic schema.xml file ready. The required fields used by the
  built in Blacklight rails views are:
    id

  Other fields are used, but specified in a configuration file:  app/config/initializers/blacklight_config.rb

  Fields that are "indexed" are searchable.

  Fields that are "stored" are can be viewed/displayed from the Solr search
  results.

  The fields with asterisks ('*') in their names are "dynamic" fields. These
  allow you to create arbitrary tags at index time.

  The *_facet field can be used for creating your facets. When you index,
  simply define a field with _facet on the end:
    category_facet

  The *_display field can be used for storing text that doesn't need to be
  indexed. An example would be the raw MARC for a record's detail view:
    raw_marc_display

  For text that will be queried (and possibly displayed), use the *_t type
  field for tokenized text (text broken into pieces/words) or the *_s type
  for queries that should exactly match the field contents:
    description_t
    url_s

  The Blacklight application is generic enough to work with any Solr schema, but to
  manipulate the search results and single record displays, you'll need to know the
  stored fields in your indexed documents.

  For more information, refer to the Solr documentation:
    http://wiki.apache.org/solr/SchemaXml

Also available in: Atom PDF