Re: Rewrite for RegexpQuery

2013-03-12 Thread Carsten Schnober
Am 12.03.2013 10:39, schrieb Uwe Schindler: > I would suggest to use my example code with the fake query and custom > rewrite. This does not have the overhead of BooleanQuery and more important: > You don't need to change the *global* and *static* default in BooleanQuery. > Otherwise you could

RE: Rewrite for RegexpQuery

2013-03-12 Thread Uwe Schindler
http://www.thetaphi.de eMail: u...@thetaphi.de > -Original Message- > From: Carsten Schnober [mailto:schno...@ids-mannheim.de] > Sent: Tuesday, March 12, 2013 10:13 AM > To: java-user@lucene.apache.org > Subject: Re: Rewrite for RegexpQuery > > Am 11.03.2013 18:22,

Re: Rewrite for RegexpQuery

2013-03-12 Thread Carsten Schnober
Am 11.03.2013 18:22, schrieb Michael McCandless: > On Mon, Mar 11, 2013 at 9:32 AM, Carsten Schnober > wrote: >> Am 11.03.2013 13:38, schrieb Michael McCandless: >>> On Mon, Mar 11, 2013 at 7:08 AM, Uwe Schindler wrote: >>> Set the rewrite method to e.g. SCORING_BOOLEAN_QUERY_REWRITE, then t

Re: Rewrite for RegexpQuery

2013-03-11 Thread Michael Sokolov
On 03/11/2013 01:22 PM, Michael McCandless wrote: On Mon, Mar 11, 2013 at 9:32 AM, Carsten Schnober wrote: Am 11.03.2013 13:38, schrieb Michael McCandless: On Mon, Mar 11, 2013 at 7:08 AM, Uwe Schindler wrote: Set the rewrite method to e.g. SCORING_BOOLEAN_QUERY_REWRITE,

RE: Rewrite for RegexpQuery

2013-03-11 Thread Uwe Schindler
Sent: Monday, March 11, 2013 6:41 PM > To: java-user@lucene.apache.org > Subject: RE: Rewrite for RegexpQuery > > I think we have here different problems: > > Carsten wants to just collect the terms a MTQ visits, so using BooleanQuery > to do this is fine, unless you hit t

RE: Rewrite for RegexpQuery

2013-03-11 Thread Uwe Schindler
m: Michael McCandless [mailto:luc...@mikemccandless.com] > Sent: Monday, March 11, 2013 6:23 PM > To: java-user@lucene.apache.org > Subject: Re: Rewrite for RegexpQuery > > On Mon, Mar 11, 2013 at 9:32 AM, Carsten Schnober mannheim.de> wrote: > > Am 11.03.2013 13:38, sc

Re: Rewrite for RegexpQuery

2013-03-11 Thread Michael McCandless
On Mon, Mar 11, 2013 at 9:32 AM, Carsten Schnober wrote: > Am 11.03.2013 13:38, schrieb Michael McCandless: >> On Mon, Mar 11, 2013 at 7:08 AM, Uwe Schindler wrote: >> >>> Set the rewrite method to e.g. SCORING_BOOLEAN_QUERY_REWRITE, then this >>> should work (after rewrite your query is a Boole

Re: Rewrite for RegexpQuery

2013-03-11 Thread Carsten Schnober
Am 11.03.2013 13:38, schrieb Michael McCandless: > On Mon, Mar 11, 2013 at 7:08 AM, Uwe Schindler wrote: > >> 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()). > > ... as long a

Re: Rewrite for RegexpQuery

2013-03-11 Thread Carsten Schnober
Am 11.03.2013 14:13, schrieb Uwe Schindler: >> 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(). > > Replace: >> BooleanQuery bq = (Boolea

RE: Rewrite for RegexpQuery

2013-03-11 Thread Uwe Schindler
> Set terms = new HashSet<>(); > MultiTermQuery query = new RegexpQuery(new Term("text", query)); > query.setRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_QUERY_RE > WRITE); > BooleanQuery bq = (BooleanQuery) query.rewrite(reader); > bq.extractTerms(terms); > > > Regarding the application of Index

Re: Rewrite for RegexpQuery

2013-03-11 Thread Michael McCandless
On Mon, Mar 11, 2013 at 7:08 AM, Uwe Schindler wrote: > 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()). ... as long as you don't exceed the max number of terms allowed by BQ (10

Re: Rewrite for RegexpQuery

2013-03-11 Thread Carsten Schnober
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. Wri

RE: Rewrite for RegexpQuery

2013-03-11 Thread Uwe Schindler
Hi, > Hi, > I'm trying to get the terms that match a certain RegexpQuery. My (naive) > approach: > > 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(rea

Re: Rewrite for RegexpQuery

2013-03-11 Thread Michael McCandless
You could call the .getTermsEnum() on the query itself, and then step through the terms and save them? But this method is protected ... so you could make a subclass w/ a new method that calls it and returns it to you. Mike McCandless http://blog.mikemccandless.com On Mon, Mar 11, 2013 at 6:41 A

Rewrite for RegexpQuery

2013-03-11 Thread Carsten Schnober
Hi, I'm trying to get the terms that match a certain RegexpQuery. My (naive) approach: 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 ter