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 Alex Thurlow <al...@blastro.com> on 2010/03/10 19:11:39 UTC

Boosting exact matches

Hi all,
     I've searched the archives and web, but I haven't found a great 
solution to this issue.  I would like to boost the results for things 
that match exactly.  For example, I have an artist field with possible 
values of:
Houston
Whitney Houston
Marques Houston

I would like the Houston results to come up first and then the other ones.

What I currently have is:
<field name="artist" type="text" indexed="true" stored="true"/>
<field name="artist_tight" type="text_ws" indexed="true" stored="true"/>
<copyField source="artist" dest="artist_tight"/>

And this is what my query looks like:
title:$search^100 OR artist:$search^100 OR description:$search^5 OR 
tags:$search^$tagboost OR title:\"$search\"~100^100 OR 
artist:\"$search\"~100^100 OR description:\"$search\"~100000^5 OR 
tags:\"$search\"~1000^$tagboost OR artist_metaphone:$search^0.2 OR 
title_metaphone:$search^0.2 or title_tight:$search^100 or 
artist_tight:$search^100

I have tried artist_tight as string, textTight, and text_ws, all to no 
avail.  I have completely deleted my index between changes and 
reinserted all my data.

What am I missing here?



-- 
Alex Thurlow
Blastro Networks

http://www.blastro.com
http://www.roxwel.com
http://www.yallwire.com


Re: Boosting exact matches

Posted by Ahmet Arslan <io...@yahoo.com>.
> So I figured out part of my
> problem.  The string field type doesn't have the
> lowercase filter on it.  I can't seem to figure out how
> to add the lowercase filter to it though.
> 
> This:
> <fieldType name="text_lower" class="solr.StrField"
> omitNorms="true">
> <analyzer type="index">
> <filter class="solr.LowerCaseFilterFactory"/>
> </analyzer>
> </fieldType>
> 
> Gives me this error.
> SEVERE: org.apache.solr.common.SolrException: analyzer
> without class or tokenizer & filter list
> 
> 
> Is there a way to have a string field that's
> case-insensitive?

Sort of. KeywordTokenizerFactory + LowerCaseFilterFactory can behave like string type. You may want to add TrimFilterFactory also. You should define it with class="solr.TextField".


      

Re: Boosting exact matches

Posted by Alex Thurlow <al...@blastro.com>.
So I figured out part of my problem.  The string field type doesn't have 
the lowercase filter on it.  I can't seem to figure out how to add the 
lowercase filter to it though.

This:
<fieldType name="text_lower" class="solr.StrField" omitNorms="true">
<analyzer type="index">
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>

Gives me this error.
SEVERE: org.apache.solr.common.SolrException: analyzer without class or 
tokenizer & filter list


Is there a way to have a string field that's case-insensitive?

Alex Thurlow
Blastro Networks

http://www.blastro.com
http://www.roxwel.com
http://www.yallwire.com


On 3/10/2010 12:11 PM, Alex Thurlow wrote:
> Hi all,
>     I've searched the archives and web, but I haven't found a great 
> solution to this issue.  I would like to boost the results for things 
> that match exactly.  For example, I have an artist field with possible 
> values of:
> Houston
> Whitney Houston
> Marques Houston
>
> I would like the Houston results to come up first and then the other 
> ones.
>
> What I currently have is:
> <field name="artist" type="text" indexed="true" stored="true"/>
> <field name="artist_tight" type="text_ws" indexed="true" stored="true"/>
> <copyField source="artist" dest="artist_tight"/>
>
> And this is what my query looks like:
> title:$search^100 OR artist:$search^100 OR description:$search^5 OR 
> tags:$search^$tagboost OR title:\"$search\"~100^100 OR 
> artist:\"$search\"~100^100 OR description:\"$search\"~100000^5 OR 
> tags:\"$search\"~1000^$tagboost OR artist_metaphone:$search^0.2 OR 
> title_metaphone:$search^0.2 or title_tight:$search^100 or 
> artist_tight:$search^100
>
> I have tried artist_tight as string, textTight, and text_ws, all to no 
> avail.  I have completely deleted my index between changes and 
> reinserted all my data.
>
> What am I missing here?
>
>
>