Dismax Request Handler

2019-06-13 15:17发布

I'm using solr to search a set of data by name (e.g. "Dan" or "Joe Smith"). I'd like to return the results specified by the query (edit: with a wildcard on the end) in an order specified by another indexed field double_score (e.g. 10.0 or 72.3). I currently have the following which fails to work at all:

<!-- Note that the default search is on the field name -->
<requestHandler name="/scoresearch" class="solr.SearchHandler" default="true">
   <!-- <lst name="invariants">
          <str name="q">{!boost b=sum(double_score) defType=dismax v=$qq}</str>
        </lst> -->
        <lst name="defaults">
          <str name="defType">dismax</str>    
          <str name="echoParams">explicit</str>
      <int name="rows">10</int>
     <!-- <str name="qq"></str> -->
      <str name="qf">double_score</str>
      <str name="debug">true</str>
      <str name="q.alt">*:*</str>
    </lst>
</requestHandler>

If I remove the comments, then the search does work s.t. whatever query I make is replaced by q.alt and then boosted by the value of double_score. If this didn't replace the q.alt, it would be the desired effect.

Also note that while I have not yet delved into more interesting possibilities such as tokenizing the names, I do plan to do so. So any possible suggestion/solution shouldn't preclude that.

2条回答
贪生不怕死
2楼-- · 2019-06-13 16:00

Try

http://localhost:8983/solr/select/?q=Joe Smith&qf=double_score^1.2 description

which means:

  1. I am looking for Joe Smith
  2. I am searching the fields double-score and description

Where description would be the field where you store text you want to search.

Make sure description has the datatype text, with

stored="true" (in case you want to return snippets)
indexed="true" (so it is searchable)

The text datatype uses filter techniques (stemming, tokenization), while string datatype processes it as such. See How to determine field-type for SOLR indexing?

查看更多
乱世女痞
3楼-- · 2019-06-13 16:06

I think you're overcomplicating it... try this:

<lst name="defaults">
    <str name="defType">edismax</str>
    <str name="qf">name</str>
    <str name="q.alt">*:*</str>
    <str name="bf">double_score</str>
</lst>
查看更多
登录 后发表回答