You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Tommy Chheng <to...@gmail.com> on 2012/03/06 07:18:05 UTC
How to rank an exact match higher?
I'm using solr 3.5 for a type ahead search system. I want to rank
exact matches(lowercased) higher than non-exact matches.
For example, if i have two docs:
Doc One: title="New York"
Doc Two: title="New York City"
I would expect a query of "new york" to rank "New York" over "New York City"
It looks like I need to take into account the # of matches vs the
total # of tokens in a field. I'm not sure how to do this.
My debug query shows the two docs with the exact scores:
<lst name="debug">
<str name="rawquerystring">"new york"</str>
<str name="querystring">"new york"</str>
<str name="parsedquery">+DisjunctionMaxQuery((title:"new york"^50.0 |
textng:"new york"^40.0))</str>
<str name="parsedquery_toString">+(title:"new york"^50.0 | textng:"new
york"^40.0)</str>
<lst name="explain">
<str name="4f553cbc03643929d093d467">1.1890696 = (MATCH) max of:
1.1890696 = (MATCH) weight(title:"new york"^50.0 in 0), product of:
0.99999994 = queryWeight(title:"new york"^50.0), product of: 50.0
= boost 1.1890697 = idf(title: new=2 york=2) 0.01681987 =
queryNorm 1.1890697 = fieldWeight(title:"new york" in 0), product
of: 1.0 = tf(phraseFreq=1.0) 1.1890697 = idf(title: new=2
york=2) 1.0 = fieldNorm(field=title, doc=0)</str>
<str name="4f553cbc03643929d093d468">1.1890696 = (MATCH) max of:
1.1890696 = (MATCH) weight(title:"new york"^50.0 in 1), product of:
0.99999994 = queryWeight(title:"new york"^50.0), product of: 50.0
= boost 1.1890697 = idf(title: new=2 york=2) 0.01681987 =
queryNorm 1.1890697 = fieldWeight(title:"new york" in 1), product
of: 1.0 = tf(phraseFreq=1.0) 1.1890697 = idf(title: new=2
york=2) 1.0 = fieldNorm(field=title, doc=1)</str>
</lst>
I posted my solrconfig/schema here:
https://gist.github.com/1984052
--
Tommy Chheng
Re: How to rank an exact match higher?
Posted by Lan <du...@gmail.com>.
Here's one way to do it using dismax.
1. You'll have two fields.
title_text which is has a type of TextField
title_string which has type String. This is an exact match field.
2. Set the dismax qf=title_string^10 title_text^1
You could even make this better by doing also handling infix searches.
Create a field title_ngram which uses the ngram type. Set dismax qf =
title_string^10 title_text^5 title_ngram^1
--
View this message in context: http://lucene.472066.n3.nabble.com/How-to-rank-an-exact-match-higher-tp3802871p3813327.html
Sent from the Solr - User mailing list archive at Nabble.com.