lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Grant Ingersoll <gsing...@apache.org>
Subject Re: Span Query on different fields
Date Tue, 18 Sep 2007 17:50:50 GMT
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


Mime
View raw message