lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shailesh Kochhar" <shailesh.koch...@gmail.com>
Subject Exposing API for scoring
Date Fri, 19 Oct 2007 01:13:07 GMT
Hi,

I'm experimenting with a few different scoring implementations and I
was wondering what the easiest way would be to incorporate a new
scorer into a searcher implementation.

>From reading the docs on Scoring at:
http://lucene.apache.org/java/2_2_0/api/org/apache/lucene/search/package-summary.html
it seems that the path of least resistance would be to create an
entire new hierarchy of class.

1. A new Query class to extend TermQuery with an appropriate
implementation of TermWeight,
2. A new Scorer class to extend TermScorer with the appropriate Scorer
implementation, and;
3. A new Similarity class which would provide the appropriate
Similarity implementations.

Given a new Query class I was at a loss when it came to instantiation.
Would something like the following work -- i.e. is it sufficient to
replace the top-level Query object, or would I need an implementation
of a QueryParser that returns instances of the derived Query type.

<pre>
    Query query = QueryParser.parse(queryString);
    ScopedQuery sq = new ScopedQuery(query);
    ScopedSimilarity ss = new ScopedSimilarity();

    Searcher searcher = new IndexSearcher("path/to/index");
    searcher.setSimilarity(ss);
    HitCollector hc = searcher.search(sq);
</pre>

With the following in ScopedQuery.ScopedWeight

<pre>
createScorer(IndexReader reader)
{
  ...

   return new ScopedScorer(this, termDocs, similarity,
reader.norms(term.field());
}
</pre>

I'm hoping that I won't need to implement a new Query parser.

Thanks,
  - Shailesh

PS: Perhaps a useful API call would be Searcher.setScorer(Scorer s),
similar to the Searcher.setSimilarity call

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


Mime
View raw message