lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Uwe Schindler" <...@thetaphi.de>
Subject RE: query.extractTerms(..) on rewritten queries
Date Mon, 06 Oct 2014 17:35:52 GMT
Hi,

Lucene no longer rewrites Wildcards and other MultiTermQueries to Boolean Queries by default,
because execution of such queries is too slow. If you just want to get the filtered index
terms, it is easiest to write your own MultiTermQuery.RewriteMethod that collects all terms
while rewriting and set it on the MultiTermQuery variant and rewrite it to collect the terms.

Uwe

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de

> -----Original Message-----
> From: Christian Reuschling [mailto:reuschling@dfki.uni-kl.de]
> Sent: Monday, October 06, 2014 6:06 PM
> To: java-user@lucene.apache.org
> Subject: query.extractTerms(..) on rewritten queries
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hi,
> 
> currently I migrate to Lucene 4. In the past, I did a trick to get the index
> specific terms for an according (wildcard) query (see below). But it don't
> works anymore:
> 
> String queryString = "n*"; // gives no result // String queryString = "nöä"; //
> results, but only the given String - not the real index terms
> 
> Query query = new QueryParser(Version.LUCENE_CURRENT, "body", new
> StandardAnalyzer(Version.LUCENE_CURRENT)).parse(queryString);
> 
> Query rewritten = searcher.rewrite(query);
> 
> HashSet<Term> hsTerms = new HashSet<>();
> 
> rewritten.extractTerms(hsTerms);
> 
> in the past, searcher.rewrite on a wildcard query results into a new
> BooleanQuery with simple TermQueries in it, representing the matching
> primitive terms from the index.
> 
> The javaDoc of the current release sounds to me that this could still work:
> 
> Searcher.rewrite:
> /**Expert: called to re-write queries into primitive queries.**/
> 
> Query.extractTerms:
> /**Expert: adds all terms occurring in this query to the terms set. Only works
> if this query is in its {@link #rewrite rewritten} form.**/
> 
> 
> 
> Thanks in advance!
> 
> Christian
> 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.19 (GNU/Linux)
> 
> iEYEARECAAYFAlQyvfoACgkQ6EqMXq+WZg9eHgCfT3dhsdJEcOxr90T3omZCJB
> hc
> qMwAn3HiT7mgExA7ok/xVMvoSTVGz//o
> =V9im
> -----END PGP SIGNATURE-----
> 
> ---------------------------------------------------------------------
> 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