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(SpanMultiTermQueryWrapper.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 | 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