Mailing List Archive

where can I register a new scorer in an existing query?
Hello,

Is there a way to supply a new Scorer implementation to an existing query?
From what I've been able to understand, the only way to provide a new
scorer is to change the scorer() method Weight, which in itself requires
implementing a new Weight, which in itself requires implementing a whole
new Query. Is there something I am missing here?

To be more concrete about what I want to achieve (maybe there is a
different / better way):
I would like to collect the *match positions* of several sub-queries, for
all matching documents. The ideal interface would be to perform search as
usual, and supply a collector that has access and collects this
information. Alternatively, to have it available in the returned results
object.

The needed information is available during search (in the internal
iterators), but I did not find a way to access it. The Weight.matches() and
SpanWeight.getSpans() methods return the iterators I'd need, but they also
require a LeafReaderContext, which I believe is only available during
search? So I thought I'd create a scorer (that gets a context and gets
called for the relevant document), but I do not see a way to supply a
custom scorer.

Any tips are greatly appreciated.

Thanks!

Yoav
Re: where can I register a new scorer in an existing query? [ In reply to ]
You could iterate manually over the leaves (IndexReader#leaves) of
your IndexReader and call Weight#matches on every leaf?

On Sat, Oct 19, 2019 at 7:41 PM Yoav Goldberg <yoav.goldberg@gmail.com> wrote:
>
> Hello,
>
> Is there a way to supply a new Scorer implementation to an existing query?
> From what I've been able to understand, the only way to provide a new
> scorer is to change the scorer() method Weight, which in itself requires
> implementing a new Weight, which in itself requires implementing a whole
> new Query. Is there something I am missing here?
>
> To be more concrete about what I want to achieve (maybe there is a
> different / better way):
> I would like to collect the *match positions* of several sub-queries, for
> all matching documents. The ideal interface would be to perform search as
> usual, and supply a collector that has access and collects this
> information. Alternatively, to have it available in the returned results
> object.
>
> The needed information is available during search (in the internal
> iterators), but I did not find a way to access it. The Weight.matches() and
> SpanWeight.getSpans() methods return the iterators I'd need, but they also
> require a LeafReaderContext, which I believe is only available during
> search? So I thought I'd create a scorer (that gets a context and gets
> called for the relevant document), but I do not see a way to supply a
> custom scorer.
>
> Any tips are greatly appreciated.
>
> Thanks!
>
> Yoav



--
Adrien

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