You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by "Jan Høydahl (Confluence)" <co...@apache.org> on 2013/08/01 23:55:00 UTC

[CONF] Apache Solr Reference Guide > Other Schema Elements

Space: Apache Solr Reference Guide (https://cwiki.apache.org/confluence/display/solr)
Page: Other Schema Elements (https://cwiki.apache.org/confluence/display/solr/Other+Schema+Elements)

Change Comment:
---------------------------------------------------------------------
Typo in element name defaultSearchKey

Edited by Jan Høydahl:
---------------------------------------------------------------------
This section describes several other important elements of {{schema.xml}}.

h2. Unique Key

The {{uniqueKey}} element specifies which field is a unique identifier for documents. Although {{uniqueKey}} is not required, it is nearly always warranted by your application design. For example, {{uniqueKey}} should be used if you will ever update a document in the index.

You can define the unique key field by naming it:

{code:xml|borderStyle=solid|borderColor=#666666}
<uniqueKey>id</uniqueKey>
{code}

Starting with Solr 4, schema defaults and {{copyFields}} cannot be used to populate the {{uniqueKey}} field. You also can't use {{UUIDUpdateProcessorFactory}} to have {{uniqueKey}} values generated automatically.

Further, the operation will fail if the {{uniqueKey}} field is used, but is multivalued (or inherits the multivalueness from the {{fieldtype}}). However, {{uniqueKey}} will continue to work, as long as the field is properly used.

h2. Default Search Field

If you are using the Lucene query parser, queries that don't specify a field name will use the {{defaultSearchField}}. The DisMax and Extended DisMax query parsers do not use this value.

{warning}
Use of the {{defaultSearchField}} element is deprecated in Solr versions 3.6 and higher. Instead, you should use the {{df}} request parameter. At some point, the {{defaultSearchField}} element may be removed.
{warning}

For more information about query parsers, see the section on [solr:Query Syntax and Parsing].

h2. Query Parser Default Operator

In queries with multiple terms, Solr can either return results where all conditions are met or where one or more conditions are met. The _operator_ controls this behavior. An operator of AND means that all conditions must be fulfilled, while an operator of OR means that one or more conditions must be true.

In {{schema.xml}}, the {{solrQueryParser}} element controls what operator is used if an operator is not specified in the query. The default operator setting only applies to the Lucene query parser, not the DisMax or Extended DisMax query parsers, which internally hard-code their operators to OR.

{warning}
The query parser default operator parameter has been deprecated in Solr versions 3.6 and higher. You are instead encouraged to specify the query parser {{q.op}} parameter in your request handler.
{warning}

h2. Similarity

Similarity is a Lucene class used to score a document in searching. This class can be changed in order to provide a more custom sorting. With Solr 4, you can configure a different {{similarity}} for each field, meaning that scoring a document will differ depending on what's in each field. However, you can still configure a global {{similarity}} is configured in the schema.xml file, where an implicit instance of {{DefaultSimilarityFactory}} is used.

A global {{<similarity>}} declaration can be used to specify a custom similarity implementation that you want Solr to use when dealing with your index. A similarity can be specified either by referring directly to the name of a class with a no-argument constructor:

{code:xml|borderStyle=solid|borderColor=#666666}
<similarity class="solr.DefaultSimilarityFactory"/>
{code}

or by referencing a {{SimilarityFactory}} implementation, which may take optional initialization parameters:

{code:xml|borderStyle=solid|borderColor=#666666}
<similarity class="solr.DFRSimilarityFactory">
  <str name="basicModel">P</str>
  <str name="afterEffect">L</str>
  <str name="normalization">H2</str>
  <float name="c">7</float>
</similarity>
{code}

Beginning with Solr 4, similarity factories can be specified on individual field types:

{code:xml|borderStyle=solid|borderColor=#666666}
<fieldType name="text_ib">
   <analyzer/>
   <similarity class="solr.IBSimilarityFactory">
      <str name="distribution">SPL</str>
      <str name="lambda">DF</str>
      <str name="normalization">H2</str>
   </similarity>
</fieldType>
{code}

This example uses {{IBSimilarityFactory}} (using the Information-Based model), but there are several similarity implementations that can be used. For Solr 4.2, {{SweetSpotSimilarityFactory}} has been added. Other options include {{BM25SimilarityFactory}}, {{DFRSimilarityFactory}}, {{SchemaSimilarityFactory}} and others. For details, see the Solr Javadocs for the [similarity factories|http://lucene.apache.org/solr/4_2_0/solr-core/org/apache/solr/search/similarities/package-summary.html].

h2. Related Topics

* [SchemaXML-Miscellaneous Settings|http://wiki.apache.org/solr/SchemaXml#Miscellaneous_Settings]
* [UniqueKey|http://wiki.apache.org/solr/UniqueKey]

{scrollbar}


Stop watching space: https://cwiki.apache.org/confluence/users/removespacenotification.action?spaceKey=solr
Change email notification preferences: https://cwiki.apache.org/confluence/users/editmyemailsettings.action