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 Daniel Bigham <da...@wolfram.com> on 2016/05/12 19:35:31 UTC
SpanNearQuery, Multiple Fields
I'm very interested in SpanNearQuery, because it allows for quite
powerful phrasal searching.
However, unlike BooleanQuery, there doesn't seem to be any way to have
it search multiple fields.
I thought I might be able to wrap multiple SpanNearQueries, each of them
searching a different field, in an outer SpanOrQuery, but that raises an
exception:
java.lang.IllegalArgumentException: Clauses must have same field.
at
org.apache.lucene.search.spans.SpanOrQuery.addClause(SpanOrQuery.java:63)
So, is there any way to do what I'd like to do? Would it require
performing multiple search operations, once per field, and then
combining the results from those multiple queries?
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: SpanNearQuery, Multiple Fields
Posted by Daniel Bigham <da...@wolfram.com>.
For some reason I had it in my head that the sub-parts of a boolean query had to either be terms or phrases, but I now see that they can be a generic Query, so your suggestion might work nicely.
I had since discovered DisjunctionMaxQuery, which might also work...
Anyway, thanks very much for your reply.
----- On May 12, 2016, at 6:48 PM, Alan Woodward <al...@flax.co.uk> wrote:
> Try adding your multiple SpanNearQuery objects to a BooleanQuery?
> Alan Woodward
> www.flax.co.uk
> On 12 May 2016, at 20:35, Daniel Bigham wrote:
>> I'm very interested in SpanNearQuery, because it allows for quite powerful
> > phrasal searching.
>> However, unlike BooleanQuery, there doesn't seem to be any way to have it search
> > multiple fields.
>> I thought I might be able to wrap multiple SpanNearQueries, each of them
>> searching a different field, in an outer SpanOrQuery, but that raises an
> > exception:
> > java.lang.IllegalArgumentException: Clauses must have same field.
> > at org.apache.lucene.search.spans.SpanOrQuery.addClause(SpanOrQuery.java:63)
>> So, is there any way to do what I'd like to do? Would it require performing
>> multiple search operations, once per field, and then combining the results from
> > those multiple queries?
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> > For additional commands, e-mail: java-user-help@lucene.apache.org
Re: SpanNearQuery, Multiple Fields
Posted by Alan Woodward <al...@flax.co.uk>.
Try adding your multiple SpanNearQuery objects to a BooleanQuery?
Alan Woodward
www.flax.co.uk
On 12 May 2016, at 20:35, Daniel Bigham wrote:
> I'm very interested in SpanNearQuery, because it allows for quite powerful phrasal searching.
>
> However, unlike BooleanQuery, there doesn't seem to be any way to have it search multiple fields.
>
> I thought I might be able to wrap multiple SpanNearQueries, each of them searching a different field, in an outer SpanOrQuery, but that raises an exception:
>
> java.lang.IllegalArgumentException: Clauses must have same field.
> at org.apache.lucene.search.spans.SpanOrQuery.addClause(SpanOrQuery.java:63)
>
> So, is there any way to do what I'd like to do? Would it require performing multiple search operations, once per field, and then combining the results from those multiple queries?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>