Am 11.03.2013 12:08, schrieb Uwe Schindler: > This works for this query, but in general you have to rewrite until it is > completely rewritten: A while loop that exits when the result of the rewrite > is identical to the original query. IndexSearcher.rewrite() does this for > you. > >> 3. Write the terms into a previously initialized empty set terms: >> Set<Term> terms = new HashSet<>(); >> q.extractTerms(terms); > > Set the rewrite method to e.g. SCORING_BOOLEAN_QUERY_REWRITE, then this > should work (after rewrite your query is a BooleanQuery, which supports > extractTerms()).
This does work for my case, thank you! For the matter of completeness, the full solution (for my specific case) is as follows: Set<Term> terms = new HashSet<>(); MultiTermQuery query = new RegexpQuery(new Term("text", query)); query.setRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE); BooleanQuery bq = (BooleanQuery) query.rewrite(reader); bq.extractTerms(terms); Regarding the application of IndexSearcher.rewrite(Query) instead: I don't see a way to set the rewrite method there because the Query's rewrite method does not seem to apply to IndexSearcher.rewrite(). 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