Op Tuesday 06 May 2008 17:39:38 schreef Paul Elschot: > Eran, > > Op Tuesday 06 May 2008 10:15:10 schreef Eran Sevi: > > Hi, > > > > I am looking for a way to filter a SpanQuery according to some > > other query (on another field from the one used for the SpanQuery). > > I need to get access to the spans themselves of course. > > I don't care about the scoring of the filter results and just need > > the positions of hits found in the documents that matches the > > filter. > > I think you'll have to implement the filtering on the Spans yourself. > That's not really difficult, just use Spans.skipTo(). > The code to do that could look sth like this (untested): > > Spans spans = yourSpanQuery.getSpans(reader); > BitSet bits = yourFilter.bits(reader); > int filterDoc = bits.nextSetBit(0); > while ((filterDoc >= 0) and spans.skipTo(filterDoc)) { > boolean more = true; > while (more and (spans.doc() == filterDoc)) { > // use spans.start() and spans.end() here > // ... > more = spans.next(); > } > if (! more) { > break; > } > filterDoc = bits.nextSetBit(spans.doc());
At this point, no skipping on the spans should be done when filterDoc equals spans.doc(), so this code still needs some work. But I think you get the idea. Regards, Paul Elschot > } > > Please check the javadocs of java.util.BitSet, there may > be a 1 off error in the arguments to nextSetBit(). > > Regards, > Paul Elschot > > > I tried looking through the archives and found some reference to a > > SpanQueryFilter patch, however I don't see how it can help me > > achieve what I want to do. This class receives only one query > > parameter (which I guess is the actual query) and not a query and a > > filter for example. > > > > Any help about how I can achieve this will be appreciated. > > > > Thanks, > > Eran. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]