You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by Apache Wiki <wi...@apache.org> on 2008/09/01 06:28:53 UTC

[Solr Wiki] Update of "SearchComponent" by HossMan

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Solr Wiki" for change notification.

The following page has been changed by HossMan:
http://wiki.apache.org/solr/SearchComponent

The comment on the change is:
rearrange some things, and add some info from SolrPlugins

------------------------------------------------------------------------------
  <!> ["Solr1.3"]  -- 
  Search components enable a [http://lucene.apache.org/solr/api/org/apache/solr/handler/component/SearchHandler.html SearchHandler] to chain together reusable pieces of functionality to create custom search handlers without writing code.
  
- There are currently several "default" [http://lucene.apache.org/solr/api/org/apache/solr/handler/component/SearchComponent.html SearchComponent]s which now comprise the default StandardRequestHandler.  They are:
+ There are currently several "default" [http://lucene.apache.org/solr/api/org/apache/solr/handler/component/SearchComponent.html SearchComponent]s which now comprise the default !SearchHandler.  They are:
-  * [http://lucene.apache.org/solr/api/org/apache/solr/handler/component/QueryComponent.html QueryComponent]
+  * query - [http://lucene.apache.org/solr/api/org/apache/solr/handler/component/QueryComponent.html QueryComponent]
-  * [http://lucene.apache.org/solr/api/org/apache/solr/handler/component/FacetComponent.html FacetComponent]
+  * facet - [http://lucene.apache.org/solr/api/org/apache/solr/handler/component/FacetComponent.html FacetComponent]
-  * [http://lucene.apache.org/solr/api/org/apache/solr/handler/component/MoreLikeThisComponent.html MoreLikeThis]
+  * mlt - [http://lucene.apache.org/solr/api/org/apache/solr/handler/component/MoreLikeThisComponent.html MoreLikeThis]
-  * [http://lucene.apache.org/solr/api/org/apache/solr/handler/component/HighlightComponent.html Highlighting]
+  * highlight - [http://lucene.apache.org/solr/api/org/apache/solr/handler/component/HighlightComponent.html Highlighting]
-  * [http://lucene.apache.org/solr/api/org/apache/solr/handler/component/DebugComponent.html Debug]
+  * debug - [http://lucene.apache.org/solr/api/org/apache/solr/handler/component/DebugComponent.html Debug]
+ 
+ These examples are enabled by default, but can be overridden by writing your own class that extends SearchComponent and then declare it in the [http://wiki.apache.org/solr/SolrConfigXml solrconfig.xml] with the appropriate name.  For instance, to override the "query" component, one would declare:
+ {{{
+ <searchComponent name="query"     class="my.app.MyQueryComponent" />
+ }}}
  
  Other useful components are:
   * SpellCheckComponent -- Exposes advanced support for spell checking such as multiple (per-field) dictionaries, loading dictionaries from files, lucene indices and Solr fields, support for analyzers, collation, query parsing and pluggable spell checker implementations. The default implementation provided with Solr uses the Lucene contrib !SpellChecker.
   * QueryElevationComponent -- Used to "elevate" results based on editorial decisions, not relevance.
- Components are enabled in the [http://wiki.apache.org/solr/SolrConfigXml solrconfig.xml].
  
+ Components can also be initialized with !NamedList params.  For example, the Query Elevator (editorial boosting) can be declared with:
- Example:
- {{{
- <searchComponent name="query"     class="org.apache.solr.handler.component.QueryComponent" />
- <searchComponent name="facet"     class="org.apache.solr.handler.component.FacetComponent" />
- <searchComponent name="mlt"       class="org.apache.solr.handler.component.MoreLikeThisComponent" />
- <searchComponent name="highlight" class="org.apache.solr.handler.component.HighlightComponent" />
- <searchComponent name="debug"     class="org.apache.solr.handler.component.DebugComponent" />
- }}}
- 
- 
- These examples are enabled by default, but can be overridden by writing your own class that extends SearchComponent and then declare it in the solrconfig.xml with the appropriate name.  For instance, to override the "query" component, one would declare:
- {{{
- <searchComponent name="query"     class="my.app.MyQueryComponent" />
- }}}
- 
- Components are initialized just like RequestHandlers, for example, the Query Elevator (editorial boosting) is declared as:
  {{{
  <searchComponent name="elevator" class="org.apache.solr.handler.component.QueryElevationComponent" >
      <!-- pick a fieldType to analyze queries -->
@@ -41, +30 @@

    </searchComponent>
  }}}
  
- Then, it can be added to an existing Request Handler by adding in the component:
+ Components can be reused by multiple instances of !SearchHandler -- either by prepending (first-components), appending (last-components), or replacing (components) the default list...
+ 
  {{{
+ <requestHandler name="/elevate" class="solr.SearchHandler">
+     <!-- add my elevator component to the end of the default list -->
- <arr name="last-components">
-   <str>elevator</str>
- </arr>
- }}}
- 
- For example, the /elevate RequestHandler uses the SearchHandler (StandardRequestHandler is a trivial extension of SearchHandler) and is declared as:
- {{{
- <requestHandler name="/elevate" class="org.apache.solr.handler.component.SearchHandler" startup="lazy">
-     <lst name="defaults">
-       <str name="echoParams">explicit</str>
-     </lst>
      <arr name="last-components">
        <str>elevator</str>
      </arr>
  </requestHandler>
+ <requestHandler name="/simple" class="solr.SearchHandler">
+     <!-- i don't want many of the defaults -->
+     <arr name="components">
+       <str>query</str>
+       <str>debug</str>
+     </arr>
+ </requestHandler>
+ 
  }}}
  
  -------