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 gsanctus <gs...@pitagora.it> on 2007/09/18 19:22:39 UTC
Span Query on different fields
Hello,
I have an index with tree fields (field1, field2,field3).
I have to do an or-query and get term positions within a document.
So I'm using span query but I have a problem because
with spans I can't write
...
SpanTermQuery field1 = new SpanTermQuery(new Term("field1", "hello"));
SpanTermQuery field2 = new SpanTermQuery(new Term("field2", "hello"));
SpanTermQuery field3 = new SpanTermQuery(new Term("field3", "hello"));
SpanOrQuery or = new SpanOrQuery(new SpanQuery[] {field1, field2,field3});
With this code I get an error because SpanOrQuery Clauses must have same
field.
My question is:
Is defined a field positions iterator on Spans or other structure ???
Can you help me???
Thanks
--
View this message in context: http://www.nabble.com/Span-Query-on-different-fields-tf4475788.html#a12761926
Sent from the Lucene - Java Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: Span Query on different fields
Posted by Grant Ingersoll <gs...@apache.org>.
I think the semantics of positions across fields isn't well defined,
which is why SpanQuery requires a single field. The workaround is to
add a 4th field that is a combo of 1, 2 and 3. Alternatively, since
you are doing an OrQuery, just process the Spans from each
SpanTermQuery separately, i.e.:
> SpanTermQuery field1 = new SpanTermQuery(new Term("field1", "hello"));
Spans f1Spans = field1.getSpans();
//do something
> SpanTermQuery field2 = new SpanTermQuery(new Term("field2", "hello"));
Spans f2Spans = field2.getSpans();
//do something
> SpanTermQuery field3 = new SpanTermQuery(new Term("field3", "hello"));
same as above.
I suppose there is some waste in this approach, since you may end up
iterating over the same doc again.
-Grant
On Sep 18, 2007, at 1:22 PM, gsanctus wrote:
>
> Hello,
> I have an index with tree fields (field1, field2,field3).
> I have to do an or-query and get term positions within a document.
> So I'm using span query but I have a problem because
> with spans I can't write
> ...
> SpanTermQuery field1 = new SpanTermQuery(new Term("field1", "hello"));
> SpanTermQuery field2 = new SpanTermQuery(new Term("field2", "hello"));
> SpanTermQuery field3 = new SpanTermQuery(new Term("field3", "hello"));
> SpanOrQuery or = new SpanOrQuery(new SpanQuery[] {field1,
> field2,field3});
> With this code I get an error because SpanOrQuery Clauses must have
> same
> field.
>
> My question is:
> Is defined a field positions iterator on Spans or other structure ???
>
> Can you help me???
>
> Thanks
> --
> View this message in context: http://www.nabble.com/Span-Query-on-
> different-fields-tf4475788.html#a12761926
> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
--------------------------
Grant Ingersoll
http://lucene.grantingersoll.com
Lucene Helpful Hints:
http://wiki.apache.org/lucene-java/BasicsOfPerformance
http://wiki.apache.org/lucene-java/LuceneFAQ
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org