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/02 22:03:56 UTC
Different weights to different fields
Hi everyone,
I'm new to Solr and just getting it set up and testing it out. I'd
like to know if there's a way to give a different weight to different
data fields.
For an example, I'm going to be storing song information. I have the
fields: Artist, Title, Description, and Tags. I'd like occurrences of
the search term in Artist and Title to count more than the ones found in
Description and Tags. For instance, a search for Bruce Springsteen
against all the fields should return the ones where artist=Bruce
Springsteen higher than ones that just have that within the
description. Is this possible either in the indexing or with a query
option?
Thanks,
Alex
--
Alex Thurlow
Blastro Networks
http://www.blastro.com
http://www.roxwel.com
http://www.yallwire.com
Re: Different weights to different fields
Posted by Erick Erickson <er...@gmail.com>.
If you get the PACKT Solr 1.4 book, there are extensive examples of this
very thing.....
It's *well* worth the time it'll save you...
Erick
On Tue, Mar 2, 2010 at 4:11 PM, Ahmet Arslan <io...@yahoo.com> wrote:
>
> > I'm new to Solr and just getting it set up
> > and testing it out. I'd like to know if there's a way
> > to give a different weight to different data fields.
> >
> > For an example, I'm going to be storing song
> > information. I have the fields: Artist, Title,
> > Description, and Tags. I'd like occurrences of the
> > search term in Artist and Title to count more than the ones
> > found in Description and Tags. For instance, a search
> > for Bruce Springsteen against all the fields should return
> > the ones where artist=Bruce Springsteen higher than ones
> > that just have that within the description. Is this
> > possible either in the indexing or with a query option?
>
> You can do it in either query time or index time. In query time you can
> assign different boost values with carat operator.
> e.g. Artist:(Bruce Springsteen)^10 Title:(Bruce Springsteen)^5
>
> Also dismax[1] request handler might useful to you.
>
> [1]http://wiki.apache.org/solr/DisMaxRequestHandler
>
> At index time you can give different boost values to different fields. [2]
> e.g. <field name="Artist" boost="10.0">
>
> [2]
> http://wiki.apache.org/solr/UpdateXmlMessages#Optional_attributes_for_.22field.22
>
>
>
>
Re: Different weights to different fields
Posted by Alex Thurlow <al...@blastro.com>.
That's great information. Thanks!
-Alex
Alex Thurlow
Blastro Networks
http://www.blastro.com
http://www.roxwel.com
http://www.yallwire.com
On 3/2/2010 3:11 PM, Ahmet Arslan wrote:
>
>> I'm new to Solr and just getting it set up
>> and testing it out. I'd like to know if there's a way
>> to give a different weight to different data fields.
>>
>> For an example, I'm going to be storing song
>> information. I have the fields: Artist, Title,
>> Description, and Tags. I'd like occurrences of the
>> search term in Artist and Title to count more than the ones
>> found in Description and Tags. For instance, a search
>> for Bruce Springsteen against all the fields should return
>> the ones where artist=Bruce Springsteen higher than ones
>> that just have that within the description. Is this
>> possible either in the indexing or with a query option?
>>
> You can do it in either query time or index time. In query time you can assign different boost values with carat operator.
> e.g. Artist:(Bruce Springsteen)^10 Title:(Bruce Springsteen)^5
>
> Also dismax[1] request handler might useful to you.
>
> [1]http://wiki.apache.org/solr/DisMaxRequestHandler
>
> At index time you can give different boost values to different fields. [2]
> e.g.<field name="Artist" boost="10.0">
>
> [2]http://wiki.apache.org/solr/UpdateXmlMessages#Optional_attributes_for_.22field.22
>
>
>
>
Re: Different weights to different fields
Posted by Ahmet Arslan <io...@yahoo.com>.
> I'm new to Solr and just getting it set up
> and testing it out. I'd like to know if there's a way
> to give a different weight to different data fields.
>
> For an example, I'm going to be storing song
> information. I have the fields: Artist, Title,
> Description, and Tags. I'd like occurrences of the
> search term in Artist and Title to count more than the ones
> found in Description and Tags. For instance, a search
> for Bruce Springsteen against all the fields should return
> the ones where artist=Bruce Springsteen higher than ones
> that just have that within the description. Is this
> possible either in the indexing or with a query option?
You can do it in either query time or index time. In query time you can assign different boost values with carat operator.
e.g. Artist:(Bruce Springsteen)^10 Title:(Bruce Springsteen)^5
Also dismax[1] request handler might useful to you.
[1]http://wiki.apache.org/solr/DisMaxRequestHandler
At index time you can give different boost values to different fields. [2]
e.g. <field name="Artist" boost="10.0">
[2]http://wiki.apache.org/solr/UpdateXmlMessages#Optional_attributes_for_.22field.22