You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Rob Clews <ro...@klearsystems.com> on 2004/07/26 17:31:44 UTC
Boosting documents
I want to do the same, set a boost for a field containing a date that
lowers as the date is further from now, is there any way I could do
this?
Also when I set a document boost at index time, with doc.setBoost(2);
then retrieve it via doc.getBoost() I always seem to get 1.0, even
though I can tell from a search that the boost works correctly. I
realise the docs say that the returned value may not be the same as the
indexed value, but should I always get 1? Essentially I'm trying to
allow an administrator to set the boost on the document through my
webapp.
Thanks
On Mon, 2004-07-26 at 17:17 +0200, Akmal Sarhan wrote:
> I want to boost those with the oldest age to have a better score for
> example but in conjunction with other criteria (therefore the new Sort
> will not help I guess)
--
Rob Clews
Klear Systems Ltd
t: +44 (0)121 707 8558 e: robc@klearsystems.com
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org
Re: tool to check the index field
Posted by Luke Shannon <ls...@hypermedia.com>.
Try this:
http://www.getopt.org/luke/
Luke
----- Original Message -----
From: "lingaraju" <li...@infactindia.com>
To: "Lucene Users List" <lu...@jakarta.apache.org>
Sent: Wednesday, November 17, 2004 10:00 AM
Subject: tool to check the index field
> HI ALL
>
> I am having index file created by other people
> Now i want to know how many field are there in the index
> Is there any third party tool to do this
> I saw some where some GUI tool to do this but forgot the name.
>
> Regards
> LingaRaju
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org
tool to check the index field
Posted by lingaraju <li...@infactindia.com>.
HI ALL
I am having index file created by other people
Now i want to know how many field are there in the index
Is there any third party tool to do this
I saw some where some GUI tool to do this but forgot the name.
Regards
LingaRaju
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org
Re: Boosting documents
Posted by Akmal Sarhan <as...@byteaction.de>.
Hallo,
I have followed your suggestion but I am not sure how it should be done
to achieve the following:
I want when I do the following search to have the score calculated so
that those with nr of kids higher get a better score and the less kids,
the less score , notice that I still want to get all documents
thanks for any input
import java.io.IOException;
import org.apache.lucene.analysis.SimpleAnalyzer;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.queryParser.ParseException;
import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.search.DefaultSimilarity;
import org.apache.lucene.search.Hits;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.Searcher;
import org.apache.lucene.store.RAMDirectory;
public class TestMatching
{
protected float f;
public static void main(String[] args) throws IOException,
ParseException
{
RAMDirectory store = new RAMDirectory();
IndexWriter writer = new IndexWriter(store, new
SimpleAnalyzer(), true);
Field f1 = Field.Text("field", "word");
Field kids1 = Field.Keyword("kids", "2");
Field kids2 = Field.Keyword("kids", "3");
Field kids3 = Field.Keyword("kids", "4");
Document d1 = new Document();
Document d2 = new Document();
Document d3 = new Document();
d1.add(f1);
d2.add(f1);
d3.add(f1);
d1.add(kids1);
d2.add(kids2);
d3.add(kids3);
d1.add(f1);
writer.addDocument(d1);
writer.addDocument(d2);
writer.addDocument(d3);
writer.optimize();
writer.close();
Searcher s = new IndexSearcher(store);
s.setSimilarity(new DefaultSimilarity() {
public float idf(Term term, Searcher searcher) throws
IOException
{
String string = term.text();
String string2 = term.field();
float f = 0.0f;
if (term.field().equals("kids"))
{
// and now ??
} else
{
f = idf(searcher.docFreq(term), searcher.maxDoc());
}
return f;
}
});
Query query = QueryParser.parse("field:word kids:5", "field",
new StandardAnalyzer());
Hits hits = s.search(query);
for (int i = 0; i < hits.length(); ++i)
{
Document doc = hits.doc(i);
System.out.println(i + " " + hits.score(i));
}
}
}
Am Mo, den 26.07.2004 schrieb Doug Cutting um 20:14:
> Rob Clews wrote:
> > I want to do the same, set a boost for a field containing a date that
> > lowers as the date is further from now, is there any way I could do
> > this?
>
> You could implement Similarity.idf(Term, Searcher) to, when
> Term.field().equals("date"), return a value that is greater for more
> recent dates.
>
> Doug
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org
>
>
> !EXCUBATOR:41054a2d101985076154790!
>
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org
Re: Boosting documents
Posted by Doug Cutting <cu...@apache.org>.
Rob Clews wrote:
> I want to do the same, set a boost for a field containing a date that
> lowers as the date is further from now, is there any way I could do
> this?
You could implement Similarity.idf(Term, Searcher) to, when
Term.field().equals("date"), return a value that is greater for more
recent dates.
Doug
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org