lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Elschot <paul.elsc...@xs4all.nl>
Subject Re: Counting hits in a document
Date Fri, 19 Jan 2007 18:55:52 GMT
Adding a few details:

On Friday 19 January 2007 06:42, Chris Hostetter wrote:
> 
> 
>     SpanQuery whatever = ...
>     Spans s = whatever.getSpans(indexReader)
     if (!s.skipTo(yourDocId)) {
        ... // no match
      } else {
>     while (s.doc() == yourDocId) {
>       print("match between " + s.start() + " and " + s.end());
         if (! s.next()) break;
>     }
    }

For performance, make sure not to go the the same disk the index is on
while using the spans like this.

In case you have multiple docs to treat, skip to them in increasing docId 
order using the same spans.

And if you ever want to write a Scorer, just add more details...

Regards,
Paul  Eschot

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


Mime
View raw message