lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Uwe Schindler" <...@thetaphi.de>
Subject RE: UnsupportedOperationException: Query should have been rewritten
Date Tue, 14 Aug 2012 09:00:24 GMT
You have to rewrite the wrapper query.

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de


> -----Original Message-----
> From: Carsten Schnober [mailto:schnober@ids-mannheim.de]
> Sent: Tuesday, August 14, 2012 10:59 AM
> To: java-user
> Subject: UnsupportedOperationException: Query should have been rewritten
> 
> Dear list,
> I am trying to combine a WildcardQuery and a SpanQuery because I need to
> extract spans from the index for further processing. I realise that there
have
> been a few public discussions about this topic around, but I still fail to
get what I
> am missing here. My code is this (Lucene 3.6.0):
> 
> ================================================================
> ======
> WildcardQuery wildcard = new WildcardQuery(new Term("field", "bro*"));
> SpanQuery query = new
> SpanMultiTermQueryWrapper<WildcardQuery>(wildcard);
> // query = query.rewrite(reader);
> Spans luceneSpans = query.getSpans(reader);
> ================================================================
> ======
> 
> This throws the following exception:
> ================================================================
> ======
> Exception in thread "main" java.lang.UnsupportedOperationException:
> Query should have been rewritten at
> org.apache.lucene.search.spans.SpanMultiTermQueryWrapper.getSpans(Span
> MultiTermQueryWrapper.java:114)
> ================================================================
> ======
> 
> I am basically aware of the problem that I cannot apply a MultiTermQuery
> instance (like a WildcardQuery) without calling rewrite(), but on the
other
> hand, rewrite() returns a Query object that I cannot use as a SpanQuery
> instance.
> 
> I'm almost sure that there is a reasonable solution for this problem that
I am
> not able to spot. Or do I have to migrate either to Lucene 4 or use a
> SpanRegexQuery instead which I do not really want to because it is marked
as
> deprecated.
> 
> Thank you very much!
> Carsten
> 
> --
> Institut für Deutsche Sprache | http://www.ids-mannheim.de
> Projekt KorAP                 | http://korap.ids-mannheim.de
> Tel. +49-(0)621-43740789      | schnober@ids-mannheim.de
> Korpusanalyseplattform der nächsten Generation Next Generation Corpus
> Analysis Platform
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org


---------------------------------------------------------------------
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