Return-Path: Delivered-To: apmail-lucene-java-dev-archive@www.apache.org Received: (qmail 63970 invoked from network); 4 Nov 2009 15:09:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 4 Nov 2009 15:09:56 -0000 Received: (qmail 99724 invoked by uid 500); 4 Nov 2009 15:09:55 -0000 Delivered-To: apmail-lucene-java-dev-archive@lucene.apache.org Received: (qmail 99635 invoked by uid 500); 4 Nov 2009 15:09:55 -0000 Mailing-List: contact java-dev-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-dev@lucene.apache.org Delivered-To: mailing list java-dev@lucene.apache.org Received: (qmail 99626 invoked by uid 99); 4 Nov 2009 15:09:55 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Nov 2009 15:09:55 +0000 X-ASF-Spam-Status: No, hits=-10.5 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Nov 2009 15:09:52 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id A607B234C1F2 for ; Wed, 4 Nov 2009 07:09:32 -0800 (PST) Message-ID: <1113022153.1257347372678.JavaMail.jira@brutus> Date: Wed, 4 Nov 2009 15:09:32 +0000 (UTC) From: "Danish Contractor (JIRA)" To: java-dev@lucene.apache.org Subject: [jira] Created: (LUCENE-2028) FilteredTermEnum.Java - The first term in the enumeration is skipped. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 FilteredTermEnum.Java - The first term in the enumeration is skipped. --------------------------------------------------------------------- Key: LUCENE-2028 URL: https://issues.apache.org/jira/browse/LUCENE-2028 Project: Lucene - Java Issue Type: Bug Components: Search Affects Versions: 2.4.1 Environment: JDK 1.6 Reporter: Danish Contractor The Filtered Term Enumeration seems to skip the first term present in the enumerator. The problem lies in the next() function, which moves does not do anything with the first value of currentTerm set by the setEnum() method. The setEnum() function sets a value to the currentTerm and returns. An implementation of WildCardTermEnum, for example calls the next() method where the currentTerm is set to null and the enumerator moves to the next value. The first term is not read. In my local workspace, I have modified the two methods - setEnum() and next() as follows: protected void setEnum(TermEnum actualEnum) throws IOException { this.actualEnum = actualEnum; this.startedReading=false; // Find the first term that matches Term term = actualEnum.term(); if (term != null && termCompare(term)) currentTerm = term; else next(); } /** Increments the enumeration to the next element. True if one exists. */ public boolean next() throws IOException { if (actualEnum == null) return false; // the actual enumerator is not initialized! if(currentTerm!=null &&!startedReading) //check if first term read { startedReading=true; return true; } currentTerm = null; while (currentTerm == null) { if (endEnum()) return false; if (actualEnum.next()) { Term term = actualEnum.term(); if (termCompare(term)) { currentTerm = term; return true; } } else return false; } currentTerm = null; return false; } I have added a boolean variable called startedReading that is a member of the FilteredTermEnum class and is set to false. Once the currentTerm set by setEnum is read, I set this value to true and the code continues as before. I have run a few of my own test cases and it returns the results I was looking for which were missing earlier as they happened to be the first term in the enumerator. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. --------------------------------------------------------------------- To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org For additional commands, e-mail: java-dev-help@lucene.apache.org