lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Carsten Schnober <schno...@ids-mannheim.de>
Subject Re: UnsupportedOperationException: Query should have been rewritten
Date Tue, 14 Aug 2012 09:06:38 GMT
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


Mime
View raw message