问题
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.
回答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>
回答2:
Try
http://localhost:8983/solr/select/?q=Joe Smith&qf=double_score^1.2 description
which means:
- I am looking for Joe Smith
- 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?
来源:https://stackoverflow.com/questions/7432163/dismax-request-handler