lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <e...@ehatchersolutions.com>
Subject Re: why the score is not 1.0?
Date Thu, 03 Jun 2004 12:43:44 GMT
Without looking at your code, a good first suggestion is to se  
IndexSearcher.explain(Query,docId) to see why scores are they way they  
are.

	Erik


On Jun 3, 2004, at 7:21 AM, uddam chukmol wrote:

> Dear all,
>
> I have another trouble in one of my program using Lucene. I tried to  
> compare the same string and use the same analyzer to index it. You can  
> see my code as following:
>
> ----------------------------------------------------------------------- 
> ------------------------------------------------------
>
> import org.apache.lucene.analysis.Analyzer;
>
> 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.queryParser.QueryParser;
>
> import org.apache.lucene.search.Hits;
>
> import org.apache.lucene.search.IndexSearcher;
>
> import org.apache.lucene.search.Query;
>
> import org.apache.lucene.search.Searcher;
>
>
>
> public class LuceneIndexExample {
>
>
>
> private static final String _indexDir ="c://lucene-index-dir";
>
>
>
> public static void main(String args[]) throws Exception {
>
>
>
> String sss = "All work and no play makes Jack a dull boy";
>
>
>
> Analyzer analyzer = new StandardAnalyzer();
>
> boolean flag = true;
>
> IndexWriter writer = new IndexWriter(_indexDir, analyzer, flag);
>
>
>
> Document document = new Document();
>
> document.add(Field.Text("champs", sss));
>
> writer.addDocument(document);
>
> writer.close();
>
>
>
> Searcher s = new IndexSearcher(_indexDir);
>
> String str = "All work and no play makes Jack a dull boy";
>
> Query q = QueryParser.parse(str, "champs", analyzer);
>
> Hits hits = s.search(q);
>
>
>
> try {
>
> for (int i=0; i<=hits.length();i++){
>
> System.out.println("score of "+ i +" = "+hits.score(i));
>
> }
>
> } catch (IndexOutOfBoundsException e){
>
> }
>
> }
>
> }
>
> ----------------------------------------------------------------------- 
> -------------------------------------------
>
> I think i should get "1.0" as the score from the hits collection but  
> got "0.30444607" instead.
>
> SOMEBODY KNOWS WHY IT'S GONE LIKE THIS? PLEASE HELP!
>
> Thanks before hand.
>
> Uddam
>
> 		
> ---------------------------------
> Do you Yahoo!?
> Friends.  Fun. Try the all-new Yahoo! Messenger


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Mime
View raw message