lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Carsten Schnober <>
Subject Rewrite for RegexpQuery
Date Mon, 11 Mar 2013 10:41:14 GMT
I'm trying to get the terms that match a certain RegexpQuery. My (naive)

1. Create a RegexpQuery from the queryString (e.g. "abc.*"):
Query q = new RegexpQuery(new Term("text", queryString));

2. Rewrite the Query using the IndexReader reader:
q = q.rewrite(reader);

3. Write the terms into a previously initialized empty set terms:
Set<Term> terms = new HashSet<>();

However, this results in an empty set. I believe this is due to the fact
that the rewritten query is a ConstantScoreQuery object;
q.extractTerms(terms) does not yield any terms anyway. q.getQuery()
returns null however; according to the documentation, this should happen
when it wraps a filter which it does not, supposedly.
This is Lucene 4.0. Any hints?

Institut für Deutsche Sprache |
Projekt KorAP                 |
Tel. +49-(0)621-43740789      |
Korpusanalyseplattform der nächsten Generation
Next Generation Corpus Analysis Platform

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message