solr 竞价

Configuration

solrconfig.xml

The query elevation component is configured in solrconfig.xml. A typical configuration may look like:

  <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>

Available arguments for the searchComponent are:

queryFieldType

Configure which fieldType should be used to analyze the incoming text. For example, it may be appropriate to use a fieldType with aLowerCaseFilter.

config-file

Path to the file that defines query elevation. This file must exist in:

<!--[if !supportLists]-->1.      <!--[endif]-->${instanceDir}/conf/${config-file} , or

<!--[if !supportLists]-->2.      <!--[endif]-->${dataDir}/${config-file}

If the file exists in the /conf/ directory it will be loaded once at start-up. If it exists in the data directory, it will be reloaded for eachIndexReader.

forceElevation

By default, this component respects the requested 'sort' parameter -- that is, if the request asks to sort by date, it will order the results by date. If forceElevation=true, results will first return the boosted docs, then order by date.

elevate.xml

Elevated query results are configured in an external .xml file determined by the config-file argument. An elevate.xml file may look like this:

<elevate>
 
 <query text="AAA">
  <doc id="A" />
  <doc id="B" />
 </query>
 
 <query text="ipod">
  <doc id="A" />
 
  <!-- you can optionally exclude documents from a query result -->
  <doc id="B" exclude="true" />
 </query>
 
</elevate>

For the above configuration, the query "AAA" would first return documents A and B, then whatever normally appears for the same query. For the query "ipod", it would first return A, and would make sure that B is not in the result set.

Usage

All standard solr features such as faceting, sorting, and MoreLikeThis work with this component installed.

enableElevation

For debugging it may be useful to see results with and without the elevated docs. To hide results use "enableElevation=false", like this:

<!--[if !supportLists]-->·         <!--[endif]--><!--[if gte vml 1]><v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"> <v:stroke joinstyle="miter" /> <v:formulas> <v:f eqn="if lineDrawn pixelLineWidth 0" /> <v:f eqn="sum @0 1 0" /> <v:f eqn="sum 0 0 @1" /> <v:f eqn="prod @2 1 2" /> <v:f eqn="prod @3 21600 pixelWidth" /> <v:f eqn="prod @3 21600 pixelHeight" /> <v:f eqn="sum @0 0 1" /> <v:f eqn="prod @6 1 2" /> <v:f eqn="prod @7 21600 pixelWidth" /> <v:f eqn="sum @8 21600 0" /> <v:f eqn="prod @7 21600 pixelHeight" /> <v:f eqn="sum @10 21600 0" /> </v:formulas> <v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect" /> <o:lock v:ext="edit" aspectratio="t" /> </v:shapetype><v:shape id="_x0000_i1025" type="#_x0000_t75" alt="[WWW]" style='width:8.25pt;height:8.25pt' o:button="t"> <v:imagedata src="file:///C:\DOCUME~1\jongo\LOCALS~1\Temp\msohtml1\01\clip_image001.gif" o:href="http://wiki.apache.org/wiki/classic/img/moin-www.png" /> </v:shape><![endif]--><!--[if !vml]--><!--[endif]--> http://localhost:8983/solr/elevate?q=YYYY&debugQuery=true&enableElevation=true

<!--[if gte vml 1]><v:shape id="_x0000_i1026" type="#_x0000_t75" alt="[WWW]" style='width:8.25pt;height:8.25pt' o:button="t"> <v:imagedata src="file:///C:\DOCUME~1\jongo\LOCALS~1\Temp\msohtml1\01\clip_image001.gif" o:href="http://wiki.apache.org/wiki/classic/img/moin-www.png" /> </v:shape><![endif]--><!--[if !vml]--><!--[endif]--> http://localhost:8983/solr/elevate?q=YYYY&debugQuery=true&enableElevation=false

fq

Query elevation respects the standard "filter query" (fq) parameter. That is, if the query contains a fq parameter, all results will be within that filter even if elevate.xml adds other documents to the result set.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值