Hi Chris,
: If I search for a document where the field boost is 0.0 then the document is
not
: found I just search that field. Is this expected???
you mean you search on: A^0 and get no results even though
documents contain A, and if you search on: +A^0 B^1 you see
those documents?
It's the index time boost, rather than query time boost. This short example
shows the behaviour of searches for
+A
+A +B
+B
where A was indexed with boost 0.0 and B with 1.0
IndexWriter writer = new IndexWriter(TestTools.getRoot(),
new StandardAnalyzer(), true);
Field f1 = new Field("subject", "subject - boost factor 0.0F",
Field.Store.YES, Field.Index.TOKENIZED);
f1.setBoost(0.0F);
Field f2 = new Field("body", "body - boost factor 1.0F", Field.Store.YES,
Field.Index.TOKENIZED);
f2.setBoost(1.0F);
Document doc = new Document();
doc.add(f1);
doc.add(f2);
writer.addDocument(doc);
writer.close();
IndexSearcher searcher = new IndexSearcher(TestTools.getRoot());
QueryParser qp;
Query query;
Hits hits;
Explanation explanation = null;
// Match on a single zero boost field
qp = new QueryParser("subject", new StandardAnalyzer());
query = qp.parse("+subject");
hits = searcher.search(query);
System.out.println("Search just subject field, no hit found with boost 0");
// Match on both fields
qp = new QueryParser("subject", new StandardAnalyzer());
query = qp.parse("+subject:subject +body:body");
hits = searcher.search(query);
System.out.println("Search +subject +body, match found, score on hit=" +
hits.score(0));
explanation = searcher.explain(query, 0);
System.out.println(explanation);
// Match on a single non zero boost field
qp = new QueryParser("body", new StandardAnalyzer());
query = qp.parse("+body:body");
hits = searcher.search(query);
System.out.println("Search just on body field=" + hits.score(0));
explanation = searcher.explain(query, 0);
System.out.println(explanation);
if you plan on using Hits, i would suggest requiring that boosts be >0 ..
if you want to start dealing with raw scores, then boosts can definitely
be 0.
Hits is sufficient for now, but that may change.
Thanks
Antony
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]