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
- < 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 >
<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:
- ${instancedir}/conf/${config-file}
${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
- < 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 --
- < Doc id="B" exclude="true" />
- </ Query >
- </ 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