lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anshum <>
Subject Re: can I set Boost to the term while indexing?
Date Thu, 20 Nov 2008 15:14:32 GMT
Hi Lin,

I guess you are looking at document boosting, if 'm right, you could
conditionally do this:
where boostFactor is a float > 1.0 that boosts the doc with the boost
Also, you could also use
field.setBoost (boostValue) to boost a particular field in a document by a
particular boostfactor.
By default all boosts are set to 1.0 in lucene. The field.setBoost would
multiply the score of all matching docs by this factor while calculating

Hope this solves your issue.

Anshum Gupta
Naukri Labs!

The facts expressed here belong to everybody, the opinions to me. The
distinction is yours to draw............

On Tue, Nov 18, 2008 at 11:07 PM, T. H. Lin <> wrote:

> I would like to store a set of keywords in a single field of a document.
> for example I have now three keywords: "One", "Two" and "Three"
> and I am going to add them into a document.
> At first, is this code correct?
> /****************************************************************/
> String[] keyword = new String[]{"One", "Two", "Three"};
> for (int i = 0; i < keyword.length; i++) {
>   Field f = new Field("field_name",
>                            keyword[i],
>                            Field.Store.NO,
>                            Field.Index.UN_TOKENIZED,
>                            TermVector.YES);
>   doc.add(f);
> }
> indexWriter.addDocument(doc);
> /***************************************************************/
> when searching, We can set Boost for a query term.
> the question is...
> Can I set Boost for every keyword/term while indexing?
> from the example above. I may set those keywords. i.e. "One", "Two" and
> "Three", with different "Weight/Boost/Relavance..." while indexing.
> and the same "term" may have different "Weight/Boost/Relavance..." in
> different document.
> can I do this?
> thanks. :-)

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message