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:08:59 GMT
Yes, cast is safe.

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