Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Lucene: Java-User

Mixing SpanQuery and BooleanQuery

 

 

Lucene java-user RSS feed   Index | Next | Previous | View Threaded


peterlkeegan at gmail

Aug 6, 2007, 10:33 AM

Post #1 of 4 (1153 views)
Permalink
Mixing SpanQuery and BooleanQuery

I'm trying to create a fairly complex SpanQuery from a binary parse tree.
I create SpanOrQueries from SpanTermQueries and combine SpanOrQueries into
BooleanQueries. So far, so good.
The problem is that I don't see how to create a SpanNotQuery from a
BooleanQuery and a SpanTermQuery. I want the BooleanQuery to be the
'include' span and the SpanTermQuery to be the 'exclude' span.
Unfortunately, the BooleanQuery cannot be cast to a SpanQuery.

I thought that SpanQuery and BooleanQuery could be freely intermixed, but
this doesn't seem to be the case. It seems that what's really needed is a
'SpanAndQuery'.

Is there another way to build this type of query?

Thanks,
Peter


erickerickson at gmail

Aug 6, 2007, 12:00 PM

Post #2 of 4 (1103 views)
Permalink
Re: Mixing SpanQuery and BooleanQuery [In reply to]

Isn't a SpanAndQuery the same as a SpanNearQuery? Perhaps
with "interesting" slops......

Erick

On 8/6/07, Peter Keegan <peterlkeegan [at] gmail> wrote:
>
> I'm trying to create a fairly complex SpanQuery from a binary parse tree.
> I create SpanOrQueries from SpanTermQueries and combine SpanOrQueries into
> BooleanQueries. So far, so good.
> The problem is that I don't see how to create a SpanNotQuery from a
> BooleanQuery and a SpanTermQuery. I want the BooleanQuery to be the
> 'include' span and the SpanTermQuery to be the 'exclude' span.
> Unfortunately, the BooleanQuery cannot be cast to a SpanQuery.
>
> I thought that SpanQuery and BooleanQuery could be freely intermixed, but
> this doesn't seem to be the case. It seems that what's really needed is a
> 'SpanAndQuery'.
>
> Is there another way to build this type of query?
>
> Thanks,
> Peter
>


peterlkeegan at gmail

Aug 6, 2007, 12:18 PM

Post #3 of 4 (1114 views)
Permalink
Re: Mixing SpanQuery and BooleanQuery [In reply to]

Even without 'interesting' slops, it does appear that SpanNearQuery is a
logical AND of all its clauses.
I was distracted by the BooleanQuery examples in the javadocs :)

thanks,
Peter

On 8/6/07, Erick Erickson <erickerickson [at] gmail> wrote:
>
> Isn't a SpanAndQuery the same as a SpanNearQuery? Perhaps
> with "interesting" slops......
>
> Erick
>
> On 8/6/07, Peter Keegan <peterlkeegan [at] gmail> wrote:
> >
> > I'm trying to create a fairly complex SpanQuery from a binary parse
> tree.
> > I create SpanOrQueries from SpanTermQueries and combine SpanOrQueries
> into
> > BooleanQueries. So far, so good.
> > The problem is that I don't see how to create a SpanNotQuery from a
> > BooleanQuery and a SpanTermQuery. I want the BooleanQuery to be the
> > 'include' span and the SpanTermQuery to be the 'exclude' span.
> > Unfortunately, the BooleanQuery cannot be cast to a SpanQuery.
> >
> > I thought that SpanQuery and BooleanQuery could be freely intermixed,
> but
> > this doesn't seem to be the case. It seems that what's really needed is
> a
> > 'SpanAndQuery'.
> >
> > Is there another way to build this type of query?
> >
> > Thanks,
> > Peter
> >
>


markrmiller at gmail

Sep 15, 2007, 8:21 AM

Post #4 of 4 (1044 views)
Permalink
Re: Mixing SpanQuery and BooleanQuery [In reply to]

Yeah, a SpanAndQuery could easily be a SpanNearQuery if a huge distance
was allowed. I do wonder how the scoring might be different based on the
distance of the match though...

Erick Erickson wrote:
> Isn't a SpanAndQuery the same as a SpanNearQuery? Perhaps
> with "interesting" slops......
>
> Erick
>
> On 8/6/07, Peter Keegan <peterlkeegan [at] gmail> wrote:
>
>> I'm trying to create a fairly complex SpanQuery from a binary parse tree.
>> I create SpanOrQueries from SpanTermQueries and combine SpanOrQueries into
>> BooleanQueries. So far, so good.
>> The problem is that I don't see how to create a SpanNotQuery from a
>> BooleanQuery and a SpanTermQuery. I want the BooleanQuery to be the
>> 'include' span and the SpanTermQuery to be the 'exclude' span.
>> Unfortunately, the BooleanQuery cannot be cast to a SpanQuery.
>>
>> I thought that SpanQuery and BooleanQuery could be freely intermixed, but
>> this doesn't seem to be the case. It seems that what's really needed is a
>> 'SpanAndQuery'.
>>
>> Is there another way to build this type of query?
>>
>> Thanks,
>> Peter
>>
>>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
For additional commands, e-mail: java-user-help [at] lucene

Lucene java-user RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.