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 balaji <mc...@gmail.com> on 2011/09/26 22:06:30 UTC

Boost Exact matches on Specific Fields

Hi all

    I am new to SOLR and have a doubt on Boosting the Exact Terms to the top
on a Particular field

For ex :

     I have a text field names ts_category and I want to give more boost to
this field rather than other fields, SO in my Query I pass the following in
the QF params "qf=body^4.0 title^5.0 ts_category^21.0" and also sort on
SCORE desc

     When I do a search against "Hospitals" . I get "Hospitalization
Management , Hospital Equipment & Supplies " on Top rather than the exact
matches of "Hospitals"

      So It would be great , If I could be helped over here


Thanks
Balaji  
   


     

    

Thanks in Advance
Balaji

--
View this message in context: http://lucene.472066.n3.nabble.com/Boost-Exact-matches-on-Specific-Fields-tp3370513p3370513.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Boost Exact matches on Specific Fields

Posted by Erick Erickson <er...@gmail.com>.
I'm not sure what you're asking here. Could you
show the results of appending &debugQuery=on
to your query? Along with what you expect to
happen and what is in the fields.

But KeywordTokenizer (in your "string_lower")
type is suspicious when you start using
multiple words. Your "agriculture foods"
query string won't match without quotes because
it'll get parsed into field:agriculture field:foods,
i.e. two tokens. But there will only be a single
token in the index because of the KeywordAnalyzer.
You might want WhitespaceTokenizer here..

Best
Erick

On Mon, Oct 3, 2011 at 2:13 PM, Balaji S <mc...@gmail.com> wrote:
> Hi
>
>   One More Question here ,  For ex: If so do an search for  "Agriculture
> Foods"  with out Quotes , It is trying to find the ones which have both the
> words not Splitting and checking for individual results . On removing the QF
> params it seems to work . Is it a problem with the QF params
>
>    I am able to see it split and trigger by checking the SOLR Analysis page
>
>
> Thanks
> Balaji
>
> On Thu, Sep 29, 2011 at 6:11 AM, Balaji S <mc...@gmail.com> wrote:
>
>> Yeah I will change the weight for str_category and make it higher . I
>> converted it to lowercase  because we cannot expect users to type them in
>> the correct case
>>
>> Thanks
>> Balaji
>>
>> On Thu, Sep 29, 2011 at 3:52 AM, Way Cool <wa...@gmail.com> wrote:
>>
>>> I will give str_category more weight than ts_category because we want
>>> str_category to win if they have "exact" matches ( you converted to
>>> lowercase).
>>>
>>> On Mon, Sep 26, 2011 at 10:23 PM, Balaji S <mc...@gmail.com> wrote:
>>>
>>> > Hi
>>> >
>>> >   You mean to say copy the String field to a Text field or the reverse .
>>> > This is the approach I am currently following
>>> >
>>> > Step 1: Created a FieldType
>>> >
>>> >
>>> >     <fieldType name="string_lower" class="solr.TextField"
>>> > sortMissingLast="true" omitNorms="true">
>>> >        <analyzer>
>>> >            <tokenizer class="solr.KeywordTokenizerFactory"/>
>>> >    <filter class="solr.LowerCaseFilterFactory" />
>>> >    <filter class="solr.TrimFilterFactory" />
>>> >        </analyzer>
>>> >     </fieldType>
>>> >
>>> > Step 2 : <field name="str_category" type="string_lower" indexed="true"
>>> > stored="true"/>
>>> >
>>> > Step 3 : <copyField source="ts_category" dest="str_category"/>
>>> >
>>> > And in the SOLR Query planning to q=hospitals&qf=body^4.0 title^5.0
>>> > ts_category^10.0 str_category^8.0
>>> >
>>> >
>>> > The One Question I have here is All the above mentioned fields will have
>>> > "Hospital" present in them , will the above approach work to get the
>>> exact
>>> > match on the top and bring "Hospitalization" below in the results
>>> >
>>> >
>>> > Thanks
>>> > Balaji
>>> >
>>> >
>>> > On Tue, Sep 27, 2011 at 9:38 AM, Way Cool <wa...@gmail.com>
>>> wrote:
>>> >
>>> > > If I were you, probably I will try defining two fields:
>>> > > 1. ts_category as a string type
>>> > > 2. ts_category1 as a text_en type
>>> > > Make sure copy ts_category to ts_category1.
>>> > >
>>> > > You can use the following as qf in your dismax:
>>> > > qf=body^4.0 title^5.0 ts_category^10.0 ts_category1^5.0
>>> > > or something like that.
>>> > >
>>> > > YH
>>> > > http://thetechietutorials.blogspot.com/
>>> > >
>>> > >
>>> > > On Mon, Sep 26, 2011 at 2:06 PM, balaji <mc...@gmail.com> wrote:
>>> > >
>>> > > > Hi all
>>> > > >
>>> > > >    I am new to SOLR and have a doubt on Boosting the Exact Terms to
>>> the
>>> > > top
>>> > > > on a Particular field
>>> > > >
>>> > > > For ex :
>>> > > >
>>> > > >     I have a text field names ts_category and I want to give more
>>> boost
>>> > > to
>>> > > > this field rather than other fields, SO in my Query I pass the
>>> > following
>>> > > in
>>> > > > the QF params "qf=body^4.0 title^5.0 ts_category^21.0" and also sort
>>> on
>>> > > > SCORE desc
>>> > > >
>>> > > >     When I do a search against "Hospitals" . I get "Hospitalization
>>> > > > Management , Hospital Equipment & Supplies " on Top rather than the
>>> > exact
>>> > > > matches of "Hospitals"
>>> > > >
>>> > > >      So It would be great , If I could be helped over here
>>> > > >
>>> > > >
>>> > > > Thanks
>>> > > > Balaji
>>> > > >
>>> > > >
>>> > > >
>>> > > >
>>> > > >
>>> > > >
>>> > > >
>>> > > > Thanks in Advance
>>> > > > Balaji
>>> > > >
>>> > > > --
>>> > > > View this message in context:
>>> > > >
>>> > >
>>> >
>>> http://lucene.472066.n3.nabble.com/Boost-Exact-matches-on-Specific-Fields-tp3370513p3370513.html
>>> > > > Sent from the Solr - User mailing list archive at Nabble.com.
>>> > > >
>>> > >
>>> >
>>>
>>
>>
>

Re: Boost Exact matches on Specific Fields

Posted by Balaji S <mc...@gmail.com>.
Hi

   One More Question here ,  For ex: If so do an search for  "Agriculture
Foods"  with out Quotes , It is trying to find the ones which have both the
words not Splitting and checking for individual results . On removing the QF
params it seems to work . Is it a problem with the QF params

    I am able to see it split and trigger by checking the SOLR Analysis page


Thanks
Balaji

On Thu, Sep 29, 2011 at 6:11 AM, Balaji S <mc...@gmail.com> wrote:

> Yeah I will change the weight for str_category and make it higher . I
> converted it to lowercase  because we cannot expect users to type them in
> the correct case
>
> Thanks
> Balaji
>
> On Thu, Sep 29, 2011 at 3:52 AM, Way Cool <wa...@gmail.com> wrote:
>
>> I will give str_category more weight than ts_category because we want
>> str_category to win if they have "exact" matches ( you converted to
>> lowercase).
>>
>> On Mon, Sep 26, 2011 at 10:23 PM, Balaji S <mc...@gmail.com> wrote:
>>
>> > Hi
>> >
>> >   You mean to say copy the String field to a Text field or the reverse .
>> > This is the approach I am currently following
>> >
>> > Step 1: Created a FieldType
>> >
>> >
>> >     <fieldType name="string_lower" class="solr.TextField"
>> > sortMissingLast="true" omitNorms="true">
>> >        <analyzer>
>> >            <tokenizer class="solr.KeywordTokenizerFactory"/>
>> >    <filter class="solr.LowerCaseFilterFactory" />
>> >    <filter class="solr.TrimFilterFactory" />
>> >        </analyzer>
>> >     </fieldType>
>> >
>> > Step 2 : <field name="str_category" type="string_lower" indexed="true"
>> > stored="true"/>
>> >
>> > Step 3 : <copyField source="ts_category" dest="str_category"/>
>> >
>> > And in the SOLR Query planning to q=hospitals&qf=body^4.0 title^5.0
>> > ts_category^10.0 str_category^8.0
>> >
>> >
>> > The One Question I have here is All the above mentioned fields will have
>> > "Hospital" present in them , will the above approach work to get the
>> exact
>> > match on the top and bring "Hospitalization" below in the results
>> >
>> >
>> > Thanks
>> > Balaji
>> >
>> >
>> > On Tue, Sep 27, 2011 at 9:38 AM, Way Cool <wa...@gmail.com>
>> wrote:
>> >
>> > > If I were you, probably I will try defining two fields:
>> > > 1. ts_category as a string type
>> > > 2. ts_category1 as a text_en type
>> > > Make sure copy ts_category to ts_category1.
>> > >
>> > > You can use the following as qf in your dismax:
>> > > qf=body^4.0 title^5.0 ts_category^10.0 ts_category1^5.0
>> > > or something like that.
>> > >
>> > > YH
>> > > http://thetechietutorials.blogspot.com/
>> > >
>> > >
>> > > On Mon, Sep 26, 2011 at 2:06 PM, balaji <mc...@gmail.com> wrote:
>> > >
>> > > > Hi all
>> > > >
>> > > >    I am new to SOLR and have a doubt on Boosting the Exact Terms to
>> the
>> > > top
>> > > > on a Particular field
>> > > >
>> > > > For ex :
>> > > >
>> > > >     I have a text field names ts_category and I want to give more
>> boost
>> > > to
>> > > > this field rather than other fields, SO in my Query I pass the
>> > following
>> > > in
>> > > > the QF params "qf=body^4.0 title^5.0 ts_category^21.0" and also sort
>> on
>> > > > SCORE desc
>> > > >
>> > > >     When I do a search against "Hospitals" . I get "Hospitalization
>> > > > Management , Hospital Equipment & Supplies " on Top rather than the
>> > exact
>> > > > matches of "Hospitals"
>> > > >
>> > > >      So It would be great , If I could be helped over here
>> > > >
>> > > >
>> > > > Thanks
>> > > > Balaji
>> > > >
>> > > >
>> > > >
>> > > >
>> > > >
>> > > >
>> > > >
>> > > > Thanks in Advance
>> > > > Balaji
>> > > >
>> > > > --
>> > > > View this message in context:
>> > > >
>> > >
>> >
>> http://lucene.472066.n3.nabble.com/Boost-Exact-matches-on-Specific-Fields-tp3370513p3370513.html
>> > > > Sent from the Solr - User mailing list archive at Nabble.com.
>> > > >
>> > >
>> >
>>
>
>

Re: Boost Exact matches on Specific Fields

Posted by Balaji S <mc...@gmail.com>.
Yeah I will change the weight for str_category and make it higher . I
converted it to lowercase  because we cannot expect users to type them in
the correct case

Thanks
Balaji

On Thu, Sep 29, 2011 at 3:52 AM, Way Cool <wa...@gmail.com> wrote:

> I will give str_category more weight than ts_category because we want
> str_category to win if they have "exact" matches ( you converted to
> lowercase).
>
> On Mon, Sep 26, 2011 at 10:23 PM, Balaji S <mc...@gmail.com> wrote:
>
> > Hi
> >
> >   You mean to say copy the String field to a Text field or the reverse .
> > This is the approach I am currently following
> >
> > Step 1: Created a FieldType
> >
> >
> >     <fieldType name="string_lower" class="solr.TextField"
> > sortMissingLast="true" omitNorms="true">
> >        <analyzer>
> >            <tokenizer class="solr.KeywordTokenizerFactory"/>
> >    <filter class="solr.LowerCaseFilterFactory" />
> >    <filter class="solr.TrimFilterFactory" />
> >        </analyzer>
> >     </fieldType>
> >
> > Step 2 : <field name="str_category" type="string_lower" indexed="true"
> > stored="true"/>
> >
> > Step 3 : <copyField source="ts_category" dest="str_category"/>
> >
> > And in the SOLR Query planning to q=hospitals&qf=body^4.0 title^5.0
> > ts_category^10.0 str_category^8.0
> >
> >
> > The One Question I have here is All the above mentioned fields will have
> > "Hospital" present in them , will the above approach work to get the
> exact
> > match on the top and bring "Hospitalization" below in the results
> >
> >
> > Thanks
> > Balaji
> >
> >
> > On Tue, Sep 27, 2011 at 9:38 AM, Way Cool <wa...@gmail.com>
> wrote:
> >
> > > If I were you, probably I will try defining two fields:
> > > 1. ts_category as a string type
> > > 2. ts_category1 as a text_en type
> > > Make sure copy ts_category to ts_category1.
> > >
> > > You can use the following as qf in your dismax:
> > > qf=body^4.0 title^5.0 ts_category^10.0 ts_category1^5.0
> > > or something like that.
> > >
> > > YH
> > > http://thetechietutorials.blogspot.com/
> > >
> > >
> > > On Mon, Sep 26, 2011 at 2:06 PM, balaji <mc...@gmail.com> wrote:
> > >
> > > > Hi all
> > > >
> > > >    I am new to SOLR and have a doubt on Boosting the Exact Terms to
> the
> > > top
> > > > on a Particular field
> > > >
> > > > For ex :
> > > >
> > > >     I have a text field names ts_category and I want to give more
> boost
> > > to
> > > > this field rather than other fields, SO in my Query I pass the
> > following
> > > in
> > > > the QF params "qf=body^4.0 title^5.0 ts_category^21.0" and also sort
> on
> > > > SCORE desc
> > > >
> > > >     When I do a search against "Hospitals" . I get "Hospitalization
> > > > Management , Hospital Equipment & Supplies " on Top rather than the
> > exact
> > > > matches of "Hospitals"
> > > >
> > > >      So It would be great , If I could be helped over here
> > > >
> > > >
> > > > Thanks
> > > > Balaji
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > Thanks in Advance
> > > > Balaji
> > > >
> > > > --
> > > > View this message in context:
> > > >
> > >
> >
> http://lucene.472066.n3.nabble.com/Boost-Exact-matches-on-Specific-Fields-tp3370513p3370513.html
> > > > Sent from the Solr - User mailing list archive at Nabble.com.
> > > >
> > >
> >
>

Re: Boost Exact matches on Specific Fields

Posted by Way Cool <wa...@gmail.com>.
I will give str_category more weight than ts_category because we want
str_category to win if they have "exact" matches ( you converted to
lowercase).

On Mon, Sep 26, 2011 at 10:23 PM, Balaji S <mc...@gmail.com> wrote:

> Hi
>
>   You mean to say copy the String field to a Text field or the reverse .
> This is the approach I am currently following
>
> Step 1: Created a FieldType
>
>
>     <fieldType name="string_lower" class="solr.TextField"
> sortMissingLast="true" omitNorms="true">
>        <analyzer>
>            <tokenizer class="solr.KeywordTokenizerFactory"/>
>    <filter class="solr.LowerCaseFilterFactory" />
>    <filter class="solr.TrimFilterFactory" />
>        </analyzer>
>     </fieldType>
>
> Step 2 : <field name="str_category" type="string_lower" indexed="true"
> stored="true"/>
>
> Step 3 : <copyField source="ts_category" dest="str_category"/>
>
> And in the SOLR Query planning to q=hospitals&qf=body^4.0 title^5.0
> ts_category^10.0 str_category^8.0
>
>
> The One Question I have here is All the above mentioned fields will have
> "Hospital" present in them , will the above approach work to get the exact
> match on the top and bring "Hospitalization" below in the results
>
>
> Thanks
> Balaji
>
>
> On Tue, Sep 27, 2011 at 9:38 AM, Way Cool <wa...@gmail.com> wrote:
>
> > If I were you, probably I will try defining two fields:
> > 1. ts_category as a string type
> > 2. ts_category1 as a text_en type
> > Make sure copy ts_category to ts_category1.
> >
> > You can use the following as qf in your dismax:
> > qf=body^4.0 title^5.0 ts_category^10.0 ts_category1^5.0
> > or something like that.
> >
> > YH
> > http://thetechietutorials.blogspot.com/
> >
> >
> > On Mon, Sep 26, 2011 at 2:06 PM, balaji <mc...@gmail.com> wrote:
> >
> > > Hi all
> > >
> > >    I am new to SOLR and have a doubt on Boosting the Exact Terms to the
> > top
> > > on a Particular field
> > >
> > > For ex :
> > >
> > >     I have a text field names ts_category and I want to give more boost
> > to
> > > this field rather than other fields, SO in my Query I pass the
> following
> > in
> > > the QF params "qf=body^4.0 title^5.0 ts_category^21.0" and also sort on
> > > SCORE desc
> > >
> > >     When I do a search against "Hospitals" . I get "Hospitalization
> > > Management , Hospital Equipment & Supplies " on Top rather than the
> exact
> > > matches of "Hospitals"
> > >
> > >      So It would be great , If I could be helped over here
> > >
> > >
> > > Thanks
> > > Balaji
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > Thanks in Advance
> > > Balaji
> > >
> > > --
> > > View this message in context:
> > >
> >
> http://lucene.472066.n3.nabble.com/Boost-Exact-matches-on-Specific-Fields-tp3370513p3370513.html
> > > Sent from the Solr - User mailing list archive at Nabble.com.
> > >
> >
>

Re: Boost Exact matches on Specific Fields

Posted by Balaji S <mc...@gmail.com>.
Hi

   You mean to say copy the String field to a Text field or the reverse .
This is the approach I am currently following

Step 1: Created a FieldType


     <fieldType name="string_lower" class="solr.TextField"
sortMissingLast="true" omitNorms="true">
        <analyzer>
            <tokenizer class="solr.KeywordTokenizerFactory"/>
    <filter class="solr.LowerCaseFilterFactory" />
    <filter class="solr.TrimFilterFactory" />
        </analyzer>
     </fieldType>

Step 2 : <field name="str_category" type="string_lower" indexed="true"
stored="true"/>

Step 3 : <copyField source="ts_category" dest="str_category"/>

And in the SOLR Query planning to q=hospitals&qf=body^4.0 title^5.0
ts_category^10.0 str_category^8.0


The One Question I have here is All the above mentioned fields will have
"Hospital" present in them , will the above approach work to get the exact
match on the top and bring "Hospitalization" below in the results


Thanks
Balaji


On Tue, Sep 27, 2011 at 9:38 AM, Way Cool <wa...@gmail.com> wrote:

> If I were you, probably I will try defining two fields:
> 1. ts_category as a string type
> 2. ts_category1 as a text_en type
> Make sure copy ts_category to ts_category1.
>
> You can use the following as qf in your dismax:
> qf=body^4.0 title^5.0 ts_category^10.0 ts_category1^5.0
> or something like that.
>
> YH
> http://thetechietutorials.blogspot.com/
>
>
> On Mon, Sep 26, 2011 at 2:06 PM, balaji <mc...@gmail.com> wrote:
>
> > Hi all
> >
> >    I am new to SOLR and have a doubt on Boosting the Exact Terms to the
> top
> > on a Particular field
> >
> > For ex :
> >
> >     I have a text field names ts_category and I want to give more boost
> to
> > this field rather than other fields, SO in my Query I pass the following
> in
> > the QF params "qf=body^4.0 title^5.0 ts_category^21.0" and also sort on
> > SCORE desc
> >
> >     When I do a search against "Hospitals" . I get "Hospitalization
> > Management , Hospital Equipment & Supplies " on Top rather than the exact
> > matches of "Hospitals"
> >
> >      So It would be great , If I could be helped over here
> >
> >
> > Thanks
> > Balaji
> >
> >
> >
> >
> >
> >
> >
> > Thanks in Advance
> > Balaji
> >
> > --
> > View this message in context:
> >
> http://lucene.472066.n3.nabble.com/Boost-Exact-matches-on-Specific-Fields-tp3370513p3370513.html
> > Sent from the Solr - User mailing list archive at Nabble.com.
> >
>

Re: Boost Exact matches on Specific Fields

Posted by Way Cool <wa...@gmail.com>.
If I were you, probably I will try defining two fields:
1. ts_category as a string type
2. ts_category1 as a text_en type
Make sure copy ts_category to ts_category1.

You can use the following as qf in your dismax:
qf=body^4.0 title^5.0 ts_category^10.0 ts_category1^5.0
or something like that.

YH
http://thetechietutorials.blogspot.com/


On Mon, Sep 26, 2011 at 2:06 PM, balaji <mc...@gmail.com> wrote:

> Hi all
>
>    I am new to SOLR and have a doubt on Boosting the Exact Terms to the top
> on a Particular field
>
> For ex :
>
>     I have a text field names ts_category and I want to give more boost to
> this field rather than other fields, SO in my Query I pass the following in
> the QF params "qf=body^4.0 title^5.0 ts_category^21.0" and also sort on
> SCORE desc
>
>     When I do a search against "Hospitals" . I get "Hospitalization
> Management , Hospital Equipment & Supplies " on Top rather than the exact
> matches of "Hospitals"
>
>      So It would be great , If I could be helped over here
>
>
> Thanks
> Balaji
>
>
>
>
>
>
>
> Thanks in Advance
> Balaji
>
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/Boost-Exact-matches-on-Specific-Fields-tp3370513p3370513.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>