Yes, cast is safe. ----- Uwe Schindler H.-H.-Meier-Allee 63, D-28213 Bremen http://www.thetaphi.de eMail: u...@thetaphi.de
> -----Original Message----- > From: Carsten Schnober [mailto:schno...@ids-mannheim.de] > Sent: Tuesday, August 14, 2012 11:07 AM > To: java-user@lucene.apache.org > Subject: Re: UnsupportedOperationException: Query should have been > rewritten > > Am 14.08.2012 11:00, schrieb Uwe Schindler: > > You have to rewrite the wrapper query. > > Thanks, Uwe! I had tried that way but it failed because the rewrite() method > would return a Query (not a SpanQuery) object. A cast seems to solve the > problem, I'm re-posting the code snippet to the list for the sake of > completeness: > > ================================================================ > WildcardQuery wildcard = new WildcardQuery(new Term("field", "bro*")); > SpanQuery query = (SpanQuery) new > SpanMultiTermQueryWrapper<WildcardQuery>(wildcard).rewrite(reader); > > Spans spans = query.getSpans(reader); > ================================================================ > > All I am still wondering about is whether this cast is totally safe, i.e. robust to > all kinds of variable search terms. > > Best, > Carsten > > -- > Institut für Deutsche Sprache | http://www.ids-mannheim.de > Projekt KorAP | http://korap.ids-mannheim.de > Tel. +49-(0)621-43740789 | schno...@ids-mannheim.de > Korpusanalyseplattform der nächsten Generation Next Generation Corpus > Analysis Platform > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org > For additional commands, e-mail: java-user-h...@lucene.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org