Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 95258 invoked from network); 5 Aug 2010 10:54:23 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 5 Aug 2010 10:54:23 -0000 Received: (qmail 11084 invoked by uid 500); 5 Aug 2010 10:54:21 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 10986 invoked by uid 500); 5 Aug 2010 10:54:18 -0000 Mailing-List: contact java-user-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-user@lucene.apache.org Delivered-To: mailing list java-user@lucene.apache.org Received: (qmail 10975 invoked by uid 99); 5 Aug 2010 10:54:17 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Aug 2010 10:54:17 +0000 X-ASF-Spam-Status: No, hits=4.7 required=10.0 tests=FREEMAIL_FROM,FREEMAIL_REPLY,HTML_MESSAGE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of anujshahwork@gmail.com designates 209.85.214.176 as permitted sender) Received: from [209.85.214.176] (HELO mail-iw0-f176.google.com) (209.85.214.176) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Aug 2010 10:54:11 +0000 Received: by mail-iw0-f176.google.com with SMTP id 37so71597iwn.35 for ; Thu, 05 Aug 2010 03:53:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type; bh=10Qaj5WRwFzfESA/8kt+94+fYit1Jan6Bqk1sSuhakk=; b=iro8UIvjPXobrc38xaICFC0XMhqhbIv7NirRzvL/YlHV7lMXecuTmFwXgLSK3eDUi/ xmkWGx0QEm/hPcy3B+/Ob6DU8KwGx212Jps1WNCaZmF39ypOk5KmEyZVzGBawZjDmVAm H4NO5HhsvPiOVdh3Jy9buh99VfJ6GktMYtKBM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=CDW557XW+2ZuvTEKj22yN2cYOeJS9dDvR4IQQEtcjX42ohqFp5DEUQjm5uZcX88F4b rwdDXB1ZH2QupMUZeRq1CtDyehLYKWDaoTqdLqW97WQcPO1sqYmyrH0jEOLLQW/VdK1M ghjTQLZuoOr6y+Bp6wWLF+jfE5NdAb/3Yd/pA= MIME-Version: 1.0 Received: by 10.231.146.135 with SMTP id h7mr11957994ibv.149.1281005631233; Thu, 05 Aug 2010 03:53:51 -0700 (PDT) Received: by 10.231.199.73 with HTTP; Thu, 5 Aug 2010 03:53:51 -0700 (PDT) In-Reply-To: References: Date: Thu, 5 Aug 2010 11:53:51 +0100 Message-ID: Subject: Re: Get fields from a Query object From: Anuj Shah To: java-user@lucene.apache.org Content-Type: multipart/alternative; boundary=001485e2eb209ae146048d115dac --001485e2eb209ae146048d115dac Content-Type: text/plain; charset=ISO-8859-1 Apologies Erick, missed your question. I'm on version 3.0 On Thu, Aug 5, 2010 at 11:52 AM, Anuj Shah wrote: > Having delved a bit more into the code it looks like every MultiTermQuery > descendant fails to implement the extractTerms method. This does make sense, > as it is not possible to list every term that satisfies a wildcard query. > > I also notice that most Query classes including the MultiTermQuery's, have > a getField method. But, this is not part of any common interface or base > class. It would be beneficial to have a public extractFields method which > operates in the same way as extractTerms. Perhaps a feature request can be > raised for this. > > I've had a go at using a regular expression on the query string, but that > is becoming extremely convoluted due to escaping, quotations and the default > fieldname. > > My only other idea is a giant recursive method which will instanceof and > casting to re-curse the entire Boolean structure of a Query object. > > > Does anyone else have any other ideas? > > Anuj > > > > > > On Tue, Aug 3, 2010 at 9:49 PM, Erick Erickson wrote: > >> Hmmmm. Assuming you called rewrite, I'm going to have to defer >> that one, I'm not familiar enough with how range queries operate. >> >> But what version of Lucene are you using? >> >> Sorry I can't be more help >> Erick >> >> On Tue, Aug 3, 2010 at 5:02 AM, Anuj Shah wrote: >> >> > Thanks, that does seem good in theory. I can get the field from each of >> the >> > terms and add them to a Set to de-dupe. >> > >> > However, in practice queries of the following nature seems to fail with >> an >> > UnsupportedOperationException: >> > field:a* >> > field:[a TO b] >> > >> > Delving into the code a bit I see the following in the Query class >> > /** >> > * Expert: adds all terms occurring in this query to the terms set. >> Only >> > * works if this query is in its {@link #rewrite rewritten} form. >> > * >> > * @throws UnsupportedOperationException if this query is not yet >> > rewritten >> > */ >> > public void extractTerms(Set terms) { >> > // needs to be implemented by query subclasses >> > throw new UnsupportedOperationException(); >> > } >> > >> > Does this imply that some concrete Query classes have not overridden >> this >> > method? >> > >> > >> > >> > >> > >> > On Mon, Aug 2, 2010 at 4:01 PM, Erick Erickson > > >wrote: >> > >> > > Did you look at Query.extractTerms? I think that'll work for you. >> > > Note that the query must be rewritten, and that the set of terms will >> > > have duplicate fields. i.e. if you search field1:Erick +field1:James >> > > I expect you'll have two terms in the set that are on field1. >> > > >> > > Best >> > > Erick >> > > >> > > On Mon, Aug 2, 2010 at 8:16 AM, Anuj Shah >> > wrote: >> > > >> > > > My code has been given a query string, which we parse into the Query >> > > object >> > > > and would like to get a list of fields from. >> > > > >> > > > I'm assuming there exists a method to do so, as it seems like a >> useful >> > > > function. If not should I be parsing the string for fields myself. >> > > > >> > > > Anuj >> > > > >> > > > >> > > > >> > > > >> > > > >> > > > On Sun, Aug 1, 2010 at 2:21 AM, Erick Erickson < >> > erickerickson@gmail.com >> > > > >wrote: >> > > > >> > > > > Could you explain more about what you're trying to do? You're >> writing >> > > the >> > > > > query >> > > > > after all, so you probably already know what went into it. >> > > > > >> > > > > Which shows that I don't understand what you want to do at all. >> > > > > >> > > > > Best >> > > > > Erick >> > > > > >> > > > > On Sat, Jul 31, 2010 at 9:41 AM, Anuj Shah < >> anujshahwork@gmail.com> >> > > > wrote: >> > > > > >> > > > > > Hi, >> > > > > > >> > > > > > Is there a way to get all the fields involved in a query? >> > > > > > >> > > > > > Thanks >> > > > > > >> > > > > > Anuj >> > > > > > >> > > > > >> > > > >> > > >> > >> > > --001485e2eb209ae146048d115dac--