Greg,

On Wednesday 16 November 2005 21:19, Greg K wrote:
> Hi All,
> 
> I'm using a bunch of SpanNearQueries combined in a SpanOrQuery to do a set
> of searches matches a phrase with a prefix search at the end. I.e.
> 
> "phrase with prefix s*" kind of thing that matches "phrase with prefix
> search" and "phrase with prefix string".
> 
> It works great and lets me quickly produce excerpts with the spans that I
> get via getSpans.
> 
> Now, however, I'd like to be able restrict the search to certain documents
> in the index, so I don't have to stream through a couple of thousand spans
> to produce the 10 excerpts on a subset of the documents.
> 
> I've tried added a term to the SpanNearQueries that targets a keyword field
> containing the document ids, but SNQ (understandably) can't handle that.
> There isn't a SpanBooleanQuery and if I wrap the SpanOrQuery in a
> BooleanQuery I'll lose access to the getSpans() method - same if I use a
> Filter - can't get spans out of a Hits object, right?
> 
...

Once you know the document numbers that you want the getSpans() to work
on, you can make a Filter for those doc nrs (set the corresponding bits
in the BitSet for the Filter) and use this FilteredQuery:
http://issues.apache.org/jira/browse/LUCENE-330
to wrap your SpanQuery.
This FilteredQuery requires skipTo(), and the scorer for
SNQ implements that, so it should work.

The FilteredQuery in 1.4.3 will score all documents regardless of whether
they are filtered out or not.

Regards,
Paul Elschot


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to