Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 63219 invoked from network); 21 Sep 2010 15:13:06 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 21 Sep 2010 15:13:06 -0000 Received: (qmail 76893 invoked by uid 500); 21 Sep 2010 15:13:04 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 76441 invoked by uid 500); 21 Sep 2010 15:13:00 -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 76433 invoked by uid 99); 21 Sep 2010 15:12:59 -0000 Received: from Unknown (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Sep 2010 15:12:59 +0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of ian.lea@gmail.com designates 209.85.216.48 as permitted sender) Received: from [209.85.216.48] (HELO mail-qw0-f48.google.com) (209.85.216.48) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Sep 2010 15:12:53 +0000 Received: by qwk3 with SMTP id 3so347121qwk.35 for ; Tue, 21 Sep 2010 08:12:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=eDwuwi4RW5sTQKR0/1VGdDQC9UBlxMWdYmIYPrtCNBY=; b=n1+m/7B8DY5wRp5zrnGr5mE8JxJopJN8jceojaA4ssXtGRcqTjRF5u7OpuZEJ5B83z q6fFj2rwOLGnaZ/tweQZX2WzWUSi3AU5Ty4zgHMHVAJB0v/1RZBjgA711x7e3ofyRYjw Lwyn+Y3XspjMfj5CQFTjZOM1cKp2UgUem4amk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=l7FVUI+p8vv8k+B+Id+FyT4JY3/Lw8DYC9LlgiAfxyRe3mrYiV6pSaiaYwSNEAKBZP +LFOgLWNcJ3Wl5TBo0AP63PrZu8FJZOqsjraXwuboEmTzq+hG79ie53L9eg1ON5gPw9i yHJTWTXQTECLFbW3zU7dYY3ywGoRbtUC9+drU= Received: by 10.229.182.3 with SMTP id ca3mr6911555qcb.173.1285081952203; Tue, 21 Sep 2010 08:12:32 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.91.196 with HTTP; Tue, 21 Sep 2010 08:12:11 -0700 (PDT) In-Reply-To: <18031.1284934863@parc.com> References: <32419.1284673156@parc.com> <16477.1284747288@parc.com> <11920.1284759921@parc.com> <18031.1284934863@parc.com> From: Ian Lea Date: Tue, 21 Sep 2010 16:12:11 +0100 Message-ID: Subject: Re: recommended way to identify a version to pass to StandardAnalyzer constructor? To: java-user@lucene.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org +1 for a static method to get the appropriate value of Version. -- Ian. On Sun, Sep 19, 2010 at 11:21 PM, Bill Janssen wrote: > Simon Willnauer wrote: > >> On Fri, Sep 17, 2010 at 11:45 PM, Bill Janssen wrote: >> > Simon Willnauer wrote: >> > >> >> On Fri, Sep 17, 2010 at 8:14 PM, Bill Janssen wrot= e: >> >> > Simon Willnauer wrote: >> >> > >> >> >> Hey Bill, >> >> >> let me clarify what Version is used for since I think that caused >> >> >> little confusion. >> >> > >> >> > Thanks. >> >> > >> >> >> The Version constant was mainly introduced to help >> >> >> users with backwards compatibility and upgrading their codebase to= a >> >> >> new version of lucene without breaking existing applications / ind= exes >> >> >> build with previous versions. For instance StandardAnalyzer preser= ves >> >> >> the positionIncrement in its StopFilter which was introduces in Lu= cene >> >> >> 2.9. If you use 2.4 and upgrade to 2.9 this change might break you= app >> >> >> since you indexed with a 2.4 behavior. You phrasequeries might not >> >> >> work as expected anymore. If you don't have any upgrade issues or = if >> >> >> you can simply reindex you might just use the latest version. >> >> > >> >> > That's what I'm trying to do. =A0But how? =A0LUCENE_CURRENT is depr= ecated! >> >> > >> >> > How about adding a constructor for StandardAnalyzer that takes no >> >> > parameters and is implicitly LUCENE_CURRENT? >> >> >> >> We deprecated LUCENE_CURRENT for a good reason that is that folks wil= l >> >> run into big trouble if they upgrade from X to X+n because behavior >> >> may change dramatically due to optimizations, bug fixes and useful >> >> features. If you blindly pass LUCENE_CURRENT you might end up with >> >> incompatible APIs in some cases (we do deploy "sophisticated backward= s >> >> layers" like we did in CharTokenizer) or query analysis which will no= t >> >> work with you existing Version X index. >> > >> > Yes, but that's not an issue if I don't *have* existing version X >> > indices, which I don't. >> Well then why don't you just use the Version.LUCENE_30 and assign it >> to some static final variable like: >> class MyConstants { public final Version LUCENE_VERSION =3D >> Version.LUCENE_30; } and use it everywhere?! > > Because that will break if what my users have installed is Lucene 2.9.3. > >> We moved away from LUCENE_CURRENT for the reasons I mentioned - if >> that made you aware of what could happen our plans worked out. > > I was already aware, but I do appreciate you folks thinking of your > users. =A0I just wish those plans had been thought out a bit more. =A0But > that's software development, isn't it :-? > >> Version of the code? I don't understand.. the max value of Version is >> your lucene version, does that help?! > > Yep. =A0That's what I'm using: > > =A0 =A0# we'd like to make this the latest Version that this Lucene knows > =A0 =A0# about, because that's what the index will be using, but using > =A0 =A0# Version.LUCENE_CURRENT is deprecated, and there's no API to map > =A0 =A0# from the Lucene version string to the Version value for that > =A0 =A0# string. =A0To make things worse, the 2.9 code doesn't support th= e > =A0 =A0# values() method, and Version doesn't implement Comparable, so I > =A0 =A0# can't just use max(). =A0So, this complexity: > > =A0 =A0def _order(v1, v2): > =A0 =A0 =A0 =A0if v1.equals(v2): > =A0 =A0 =A0 =A0 =A0 =A0return 0 > =A0 =A0 =A0 =A0if v1.onOrAfter(v2): > =A0 =A0 =A0 =A0 =A0 =A0return 1 > =A0 =A0 =A0 =A0else: > =A0 =A0 =A0 =A0 =A0 =A0return -1 > =A0 =A0_values =3D sorted([getattr(Version, x) for x in Version.__dict__ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (x.startswith("LUCENE") and= (x !=3D "LUCENE_CURRENT"))], > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 cmp=3D_order) > =A0 =A0_indexversion =3D _values[-1] > =A0 =A0del _order, _values > > >> > Or, is there a method which will take a Lucene version, expressed as a >> > Package or perhaps even a string like "3.0.2", and return the >> > appropriate Version value? =A0If so, I could write my own code to retr= ieve >> > the Lucene version, then call that method to retrieve the Version valu= e. >> >> org.apache.lucene.util.Constants#LUCENE_MAIN_VERSION >> org.apache.lucene.util.Constants#LUCENE_VERSION > > Yes, those are the strings I would use. =A0Now, how do I map from that > string to an appropriate value of Version? =A0I think Version should grow > a static method for doing that: > > =A0Version theVersion =3D Version.valueOf(Constants.LUCENE_MAIN_VERSION); > > Thanks, > > Bill > > --------------------------------------------------------------------- > 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