lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott Phillips" <>
Subject Re: Field rank?
Date Fri, 12 Oct 2007 15:14:13 GMT
Thank you Doron & Kyle,

You both pointed me in the right direction. For anyone finding this
thread in the email archive, here is what I've learned.

You can boost field weights either at indexing time or at query time.
For indexing time you call .setBoost(float) on the field before it has
been added to the document. Alternatively you can can provide a
HashMap of the field names & boosts at query time when using the third
pramater of the MultiFieldQueryParser.

In either case you must use the MultiFieldQueryParser to parse the
query, otherwise you'll only be searching against one specific index
and it won't matter what weight they are boosted by. In this case
you'll need to pass the parser all the possible search fields to
combine together. In effect this will run your query against each
index and then merge the results together. I am not sure of what
performance impact this will have.


On 10/10/07, Kyle Maxwell <> wrote:
> > I have a question that I can't quite seem to find the answer to by
> > googling or searching the archives of this mailing list. The problem
> > is I would like to weight some fields more than others. Assume that I
> > have three fields: title, author, and default where title and author
> > contain there respective attributes and default contains all text
> > extracted from the document. When a user searches for 'foo' i would to
> > see at the top of the result list documents that contain 'foo' in the
> > title.
> >
> > Looking through the archive I see i could re-craft my user's query as such:
> >
> > (title: foo)^3 OR (author: foo)^2 OR (default: foo)
> >
> > But this doesn't seem very elegant of a solution to the problem and
> > becomes more problematic as the number of fields increase. Also I'm
> > not sure if this is possible if the user entered more complex
> > queries...
> One of the MultiFieldQueryParser's constructors has a field boost argument.
> --
> Kyle Maxwell
> Software Engineer
> CastTV, Inc
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message