Raza
Raza

Reputation: 139

Solrnet: How to use QueryelevationComponent in .net?

I am using SolrNet for site search. However, now I need to show some documents at the top for specific queries. I went through the Query Elevation manual http://wiki.apache.org/solr/QueryElevationComponent and set up solrconfig.xml accordingly. The the debugging url mentioned in the manual is working pretty well.

I just don't know how to use Query elevation component with Solrnet. I cannot find any code example in SolrNet wiki that shows how to use elevate.xml. Any example, suggestion will be highly appreciated.

Upvotes: 1

Views: 755

Answers (2)

Paige Cook
Paige Cook

Reputation: 22555

Based on the QueryElevatorComponent documentation on the wiki, you have a few options for enabling this for use with the SolrNet client.

  1. You can add the following parameter to your SolrNet client query, to tell Solr to use the elevate RequestHandler instead of the default.

    solr.Query("ipod", new QueryOptions {
         ExtraParams = new Dictionary<string, string> {
            {"qt", "elevate"}
         }
     });
    
  2. Modify your default request handler in the solrconfig.xml file to add the elevate component as last-component. Below is a modified version of solrconfig.xml that comes with the Solr distribution sample file. Note: This assumes that you have the elevator searchcComponent defined as shown in the wiki page.

    <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>
    
      ...
    
      <arr name="last-components">
        <str>elevator</str>
      </arr>
    </requestHandler>
    

Upvotes: 2

Mauricio Scheffer
Mauricio Scheffer

Reputation: 99750

There is nothing you need to do client-side (i.e. in SolrNet) to activate this feature. It's configured and activated purely server-side.

Upvotes: 1

Related Questions