You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Peter Keegan <pe...@gmail.com> on 2007/08/06 19:33:53 UTC
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
Re: Mixing SpanQuery and BooleanQuery
Posted by Peter Keegan <pe...@gmail.com>.
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 <er...@gmail.com> wrote:
>
> Isn't a SpanAndQuery the same as a SpanNearQuery? Perhaps
> with "interesting" slops......
>
> Erick
>
> On 8/6/07, Peter Keegan <pe...@gmail.com> 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
> >
>
Re: Mixing SpanQuery and BooleanQuery
Posted by Mark Miller <ma...@gmail.com>.
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 <pe...@gmail.com> 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@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: Mixing SpanQuery and BooleanQuery
Posted by Erick Erickson <er...@gmail.com>.
Isn't a SpanAndQuery the same as a SpanNearQuery? Perhaps
with "interesting" slops......
Erick
On 8/6/07, Peter Keegan <pe...@gmail.com> 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
>