Bid ranking implementation in SOLR

Source: Internet
Author: User
Tags solr

In general, Lucene only returns documents related to user queries, and the results of the search are related to the document scoring with Lucene. In real-world queries, we sometimes need to specify the location of their search results for certain documents. solr1.3 's newly-pushed component Queryelevationcomponent implements this functionality.

How to configure in Solrconfig.xml

The following is an example of a configuration in Solrconfig.xml:

XML code
  1. < searchcomponent name="Elevator" class="org.apache.solr.handler.component.QueryElevationComponent " >
  2. < Str name="Queryfieldtype">string</str>
  3. < Str name="Config-file">elevate.xml</str>
  4. </ searchcomponent >
  5. < RequestHandler name="/elevate" class="SOLR." Searchhandler ">
  6. < LST name="Defaults">
  7. < Str name="Echoparams">explicit</str>
  8. </ LST >
  9. < arr name="last-components">
  10. < Str >Elevator</str>
  11. </ arr >
  12. </ RequestHandler >
<searchcomponent name= "Elevator" class= "org.apache.solr.handler.component.QueryElevationComponent" >    <str name= "Queryfieldtype" >string</str>    <str name= "Config-file" >elevate.xml</str>  </searchComponent>  <requesthandler name= "/elevate" class= "SOLR. Searchhandler ">    <lst name=" Defaults ">      <str name=" Echoparams ">explicit</str>    </lst>    <arr name= "last-components" >      <str>elevator</str>    </arr>  </requestHandler>

Queryfieldtype

This parameter specifies the type of the input query parameter.

Config-file

This parameter specifies the path to the elevation configuration file. This file must exist in the following two locations:

    1. ${instancedir}/conf/${config-file}
    2. ${datadir}/${config-file}

If the configuration file is in the/conf/directory, it will only be loaded when the project is started. If the configuration file is actually in the data directory, it will be loaded when the Indexreader is instantiated.

Forceelevation

By default, this component respects the "sort" parameter, which is how to say it. For example, if a request requires data ordering, which is sort, then the component returns the result sorted by date. We set Forceelevation to True, then the result set will first return the document we specified.

Configure Elevate.xml

How to specify what content to specify. is configured in the Elevate.xml file. The following is an example of a elevate.xml file.

XML code
  1. < Elevate >
  2. < Query text="AAA">
  3. < Doc id="A" />
  4. < Doc id="B" />
  5. </ Query >
  6. < Query text="ipod">
  7. < Doc id="A" />
  8. <!--can optionally exclude documents from a query result --
  9. < Doc id="B" exclude="true" />
  10. </ Query >
  11. </ Elevate >
<elevate> <query text= "AAA" >  <doc id= "A"/>  <doc id= "B"/> </query> <query text= "ipod" >  <doc id= "a"/>  <!--can optionally exclude documents from A query result-----  & Lt;doc id= "B" exclude= "true"/> </query></elevate>

In this configuration file above, when the "AAA" is queried, it returns document A, and document B, and then other related documents.

Bid ranking implementation in SOLR

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.