0

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.

javanna
  • 59,145
  • 14
  • 144
  • 125
user592419
  • 5,103
  • 9
  • 42
  • 67

2 Answers2

1

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>
Mauricio Scheffer
  • 98,863
  • 23
  • 192
  • 275
0

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?

Community
  • 1
  • 1
Jesvin Jose
  • 22,498
  • 32
  • 109
  • 202
  • So I tried doing that (already had description set to text) and found that it didn't actually work. I had to put the full name of the search in before any search was successful. This means something like "Dan" only returns "Dan"s and no "Danielles." (I should have specified "Dan*" in the original post, my apologies). So I then tried using edismax and that did work, except with the qf field. What do you recommend doing here, going with edismax and figuring out what to do there with qf or implement something else relevant for dismax? Thanks again. – user592419 Sep 15 '11 at 20:12
  • It is faulty when searching "Dan" doesnt return "Dan Brown", dunno about "Daniells". Check http://stackoverflow.com/questions/3208311/wildcard-searches-using-dismax-handler too (I checked that out myself). And Mauricio's answer makes sense, setting the bf (boost field). – Jesvin Jose Sep 16 '11 at 05:57