Add spellchecking to default request handler
authorDennis Schafroth <dennis@indexdata.com>
Mon, 31 Oct 2011 12:54:53 +0000 (13:54 +0100)
committerDennis Schafroth <dennis@indexdata.com>
Mon, 31 Oct 2011 12:54:53 +0000 (13:54 +0100)
solr-conf/solrconfig.xml

index c281730..823cf50 100644 (file)
        queries across multiple shards
     -->
   <requestHandler name="search" class="solr.SearchHandler" default="true">
        queries across multiple shards
     -->
   <requestHandler name="search" class="solr.SearchHandler" default="true">
-    <!-- default values for query parameters can be specified, these
-         will be overridden by parameters in the request
-      -->
-     <lst name="defaults">
-       <str name="echoParams">explicit</str>
-       <int name="rows">10</int>
-     </lst>
-    <!-- In addition to defaults, "appends" params can be specified
-         to identify values which should be appended to the list of
-         multi-val params from the query (or the existing "defaults").
-      -->
-    <!-- In this example, the param "fq=instock:true" would be appended to
-         any query time fq params the user may specify, as a mechanism for
-         partitioning the index, independent of any user selected filtering
-         that may also be desired (perhaps as a result of faceted searching).
-
-         NOTE: there is *absolutely* nothing a client can do to prevent these
-         "appends" values from being used, so don't use this mechanism
-         unless you are sure you always want it.
-      -->
-    <!--
-       <lst name="appends">
-         <str name="fq">inStock:true</str>
-       </lst>
-      -->
-    <!-- "invariants" are a way of letting the Solr maintainer lock down
-         the options available to Solr clients.  Any params values
-         specified here are used regardless of what values may be specified
-         in either the query, the "defaults", or the "appends" params.
-
-         In this example, the facet.field and facet.query params would
-         be fixed, limiting the facets clients can use.  Faceting is
-         not turned on by default - but if the client does specify
-         facet=true in the request, these are the only facets they
-         will be able to see counts for; regardless of what other
-         facet.field or facet.query params they may specify.
-
-         NOTE: there is *absolutely* nothing a client can do to prevent these
-         "invariants" values from being used, so don't use this mechanism
-         unless you are sure you always want it.
-      -->
-    <!--
-       <lst name="invariants">
-         <str name="facet.field">cat</str>
-         <str name="facet.field">manu_exact</str>
-         <str name="facet.query">price:[* TO 500]</str>
-         <str name="facet.query">price:[500 TO *]</str>
-       </lst>
-      -->
-    <!-- If the default list of SearchComponents is not desired, that
-         list can either be overridden completely, or components can be
-         prepended or appended to the default list.  (see below)
-      -->
-    <!--
-       <arr name="components">
-         <str>nameOfCustomComponent1</str>
-         <str>nameOfCustomComponent2</str>
-       </arr>
-      -->
-    </requestHandler>
-
+    <lst name="defaults">
+      <str name="echoParams">explicit</str>
+      <str name="spellcheck.dictionary">text</str>
+      <!-- omp = Only More Popular -->
+      <str name="spellcheck.onlyMorePopular">false</str>
+      <!-- exr = Extended Results -->
+      <str name="spellcheck.extendedResults">true</str>
+      <!--  The number of suggestions to return -->
+      <str name="spellcheck.count">5</str>
+    </lst>
+    <arr name="last-components">
+      <str>spellcheck</str>
+    </arr>
+  </requestHandler>
+    
   <!-- A Robust Example
 
        This example SearchHandler declaration shows off usage of the
   <!-- A Robust Example
 
        This example SearchHandler declaration shows off usage of the
      -->
   <searchComponent name="spellcheck" class="solr.SpellCheckComponent">
 
      -->
   <searchComponent name="spellcheck" class="solr.SpellCheckComponent">
 
-    <str name="queryAnalyzerFieldType">textSpell</str>
-
-    <!-- Multiple "Spell Checkers" can be declared and used by this
-         component
-      -->
+    <str name="queryAnalyzerFieldType">text</str>
 
 
-    <!-- a spellchecker built from a field of the main index, and
-         written to disk
-      -->
     <lst name="spellchecker">
     <lst name="spellchecker">
-      <str name="name">default</str>
-      <str name="field">name</str>
-      <str name="spellcheckIndexDir">spellchecker</str>
+       <str name="classname">solr.IndexBasedSpellChecker</str>
+       <str name="name">text</str>
+       <str name="field">text</str>
+       <str name="buildOnOptimize">true</str>
+       <str name="spellcheckIndexDir">./spellchecker</str>
       <!-- uncomment this to require terms to occur in 1% of the documents in order to be included in the dictionary
        <float name="thresholdTokenFrequency">.01</float>
       -->
     </lst>
 
       <!-- uncomment this to require terms to occur in 1% of the documents in order to be included in the dictionary
        <float name="thresholdTokenFrequency">.01</float>
       -->
     </lst>
 
+
     <!-- a spellchecker that uses a different distance measure -->
     <!--
        <lst name="spellchecker">
     <!-- a spellchecker that uses a different distance measure -->
     <!--
        <lst name="spellchecker">