Boosting in version 1.2

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Boosting in version 1.2

Thierry Collogne
Hello,

Our documents contain three fields. title, keywords, content.
What we want is to give priority to the field keywords, than title and last
content.

So we did the following in our xml file that is to be indexed we put the
following

<doc>
  <field name="keywords" boost="3.0">letters</field>
  <field name="title" boost="2.0">This is a test</field>
  <field name="content"><![CDATA[This is a test]]></field>
</doc>
<doc>
  <field name="keywords" boost="3.0">foobar</field>
  <field name="title" boost="2.0">This is a test letters</field>
  <field name="content"><![CDATA[This is a test]]></field>
</doc>
<doc>
  <field name="keywords" boost="3.0">foobar</field>
  <field name="title" boost="2.0">This is a test</field>
  <field name="content"><![CDATA[This is a test letters]]></field>
</doc>

In our schema.xml we have put

<defaultSearchField>text</defaultSearchField>

 <copyField source="titlesearch" dest="text"/>
 <copyField source="keywords" dest="text"/>
 <copyField source="content" dest="text"/>

No when we do a search like this

http://localhost:8666/solr/select/?q=letters&version=2.2&start=0&rows=10&indent=on

We don't always get the document with letters in keywords on top. To get
this to work, we need to specify the 3 search fields like this

http://localhost:8666/solr/select/?q=content%3Aletters+OR+titlesearch%3Aletters+OR+keywords%3Aletters&version=2.2&start=0&rows=10&indent=on

I was wondering if there is a way in Solr 1.2 to specify more than one
default search field, or is the above solution still the way to go?

Thank you,

Thierry
Reply | Threaded
Open this post in threaded view
|

Re: Boosting in version 1.2

Mike Klaas
On 8-Jun-07, at 2:07 AM, Thierry Collogne wrote:

> Hello,
>
> Our documents contain three fields. title, keywords, content.
> What we want is to give priority to the field keywords, than title  
> and last
> content
<>

> In our schema.xml we have put
>
> <defaultSearchField>text</defaultSearchField>
>
> <copyField source="titlesearch" dest="text"/>
> <copyField source="keywords" dest="text"/>
> <copyField source="content" dest="text"/>
>
> No when we do a search like this
>
> http://localhost:8666/solr/select/?
> q=letters&version=2.2&start=0&rows=10&indent=on
>
> We don't always get the document with letters in keywords on top.  
> To get
> this to work, we need to specify the 3 search fields like this

I'm surprised that that finds anything--you've specified a  
defaultSearchField that doesn't exist in the documents you posted.

> http://localhost:8666/solr/select/?q=content%3Aletters+OR 
> +titlesearch%3Aletters+OR+keywords%
> 3Aletters&version=2.2&start=0&rows=10&indent=on
>
> I was wondering if there is a way in Solr 1.2 to specify more than one
> default search field, or is the above solution still the way to go?

This is precisely the situation that the dismax handler was designed  
for.  Plus, you don't have to fiddle around with document boosts.

try:

  qt=dismax q=letters qf=keywords^3.0 title^2.0 content

-Mike