Solr Components

How to add components to search handlers?

If you want to have a custom list of components (either omitting defaults or adding custom components) you can specify the components for a handler directly:

   <arr name="components">
     <str>query</str>
     <str>facet</str>
     <str>mlt</str>
     <str>highlight</str>
     <str>debug</str>
     <str>someothercomponent</str>
   </arr>

You can add components before or after the main ones like this:

   <arr name="first-components">
     <str>mycomponent</str>
   </arr>

   <arr name="last-components">
     <str>myothercomponent</str>
   </arr>

Note that the any component used (except the defaults) must itself be configured in solrconfig.xml with the name used in the str element as well. See SearchComponent for more details.

Search Components:

Components can also be initialized with NamedList params. For example, the Query Elevator (editorial boosting) can be declared with:

<searchComponent name="elevator" class="org.apache.solr.handler.component.QueryElevationComponent" >
    <!-- pick a fieldType to analyze queries -->
    <str name="queryFieldType">string</str>
    <str name="config-file">elevate.xml</str>
</searchComponent>

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>
</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>
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License