|
List Info
Thread: Exposing API for scoring
|
|
| Exposing API for scoring |

|
2007-10-18 20:13:07 |
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/ja
va/2_2_0/api/org/apache/lucene/search/package-summary.html
a>
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
|
|
[1]
|
|
|
about | contact Other archives ( Real Estate discussion Medical topics )
|