lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Marcus Falck" <marcus.fa...@observer.se>
Subject Boost problems
Date Wed, 17 May 2006 13:43:51 GMT
Hello,

 

I have run in to problems regarding boosting of documents, using
lucene.net 1.4.3 (so if anybody runs the java version and feel for
running my posted source code please do so and see if the result is the
same).

 

The following code:

       // The following example illustrates the boost problematic

       Document doc = new Document();

       doc.Add(Field.Text("BodyText", "My name is Marcus"));

       doc.SetBoost(2); // <-- Set the boost to 2

 

       // Create index

IndexWriter iw = new IndexWriter(@"c:\ixtest", new StandardAnalyzer(),
true);

       iw.AddDocument(doc);

       iw.Optimize();

       iw.Close();

 

       // Search

       Searcher s = new IndexSearcher(@"c:\ixtest");

       Query q = QueryParser.Parse("BodyText:name",null, new
StandardAnalyzer());

       

       Hits h = s.Search(q);

       Console.WriteLine( h.Doc(0).GetField("BodyText").StringValue() );

       Console.WriteLine( h.Doc(0).GetBoost());

       s.Close();

 

Outputs:

My name is Marcus

1

 

Why does it reply with 1 as boost? Shouldn't this value be 2?

 

/

Regards 

Marcus 

 


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