lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Hostetter <hossman_luc...@fucit.org>
Subject Re: Counting hits in a document
Date Fri, 19 Jan 2007 05:42:29 GMT

: It was late this afternooon and I was square-eyed, so I didn't add the
: detail. The app we're working on first returns a summary list of all the
: books that match a query, no hit information. Next, the user clicks on a
: returned title and we show the hits by chapter. That is, a list of chapters
: and the count of the hits for each. The index is nearing 15G at present, so
: I *assumed* that I really didn't want to re-query the entire index when I
: know the particular document I care about already. But what do I know?

i never said anything about requerying the whole index, i said skipTo the
docid you care about...

one the second user click, figure out the docid (do a TermQuery or
an indexReader.termDocs on a Term containing whatever unique id you have
for each title) then do something like this using whatever SpanQuery you
want (it doesn't have to be your orriginal SpanQuery, it could be a
SpanTermQuery that was part of your larger SpanQuery) ...

    SpanQuery whatever = ...
    Spans s = whatever.getSpans(indexReader)
    s.skipTo(yourDocId);
    while (s.doc() == yourDocId) {
      print("match between " + s.start() + " and " + s.end());
      s.next();
    }


-Hoss

---------------------------------------------------------------------
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