Return-Path: X-Original-To: apmail-lucene-java-user-archive@www.apache.org Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9CB5ACDA4 for ; Mon, 17 Nov 2014 15:40:24 +0000 (UTC) Received: (qmail 59808 invoked by uid 500); 17 Nov 2014 15:40:22 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 59744 invoked by uid 500); 17 Nov 2014 15:40:22 -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 59730 invoked by uid 99); 17 Nov 2014 15:40:22 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Nov 2014 15:40:22 +0000 X-ASF-Spam-Status: No, hits=1.7 required=5.0 tests=FREEMAIL_ENVFROM_END_DIGIT,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of b.coughlan2@gmail.com designates 209.85.214.181 as permitted sender) Received: from [209.85.214.181] (HELO mail-ob0-f181.google.com) (209.85.214.181) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Nov 2014 15:39:55 +0000 Received: by mail-ob0-f181.google.com with SMTP id gq1so3477038obb.12 for ; Mon, 17 Nov 2014 07:39:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=H+T3GvQ4BAtA/6YPVTp5cF04FgGoHQGzm9MTDTuVfw4=; b=PFmKWiA8xUH0qUIp7EUZN633kjahJUywiO3WIN4XLynmoCkiCEUtRXKPMG3TFv6IqD 1SdnLLN/wKI/Rg3VttqiBNfjUEv0/kbjja49pcb59/8TWkskmbUXgF2UIyDS9CB3PWvb wYTAzecj4Qv6KVN4IGMkc5qFBHhGXsjBBQjDeELL+ANvEuyKh2XNzGe+o311fEy50dZE wnhgCRp1U/Aj6gR3KXIwbzxU2WcZabDKPRlzmIa6R8CC2fwM//duawo/NkEqOBC8Xe3t VXx6DsujB1h47zuUk7prlPuEoDwefPyRDXZdA7d+FdvOA+NBkRK1a9fNblV57JgJwJZ6 6uWg== MIME-Version: 1.0 X-Received: by 10.60.130.201 with SMTP id og9mr539103oeb.86.1416238794333; Mon, 17 Nov 2014 07:39:54 -0800 (PST) Received: by 10.76.8.41 with HTTP; Mon, 17 Nov 2014 07:39:54 -0800 (PST) Date: Mon, 17 Nov 2014 15:39:54 +0000 Message-ID: Subject: Iterating TermsEnum for Long field produces zero values at the end From: Barry Coughlan To: java-user@lucene.apache.org Content-Type: multipart/alternative; boundary=089e0122aae240e38f05080fcaf9 X-Virus-Checked: Checked by ClamAV on apache.org --089e0122aae240e38f05080fcaf9 Content-Type: text/plain; charset=UTF-8 Hi all, I'm using 4.10.2. I have a Long "id" field. Each document has one "id" value. I am creating a look-up between Lucene's internal document id and my "id" values by enumerating the inverted index: private long[] cacheDocIds() throws IOException { long[] ourIds = new long[reader.maxDoc()]; Bits liveDocs = MultiFields.getLiveDocs(reader); Fields fields = MultiFields.getFields(reader); Terms terms = fields.terms("id"); TermsEnum iterator = terms.iterator(null); BytesRef bytesRef = null; while ((bytesRef = iterator.next()) != null) { DocsEnum docsEnum = iterator.docs(liveDocs, null, DocsEnum.FLAG_NONE); int luceneId = docsEnum.nextDoc(); long ourId = NumericUtils.prefixCodedToLong(bytesRef); System.out.println(luceneId + " " + ourId); ourIds[luceneId] = ourId; } return ourIds; } With 5 documents (1, 2, 3, 4, 5) I get this output from the above code: 0 1 1 2 2 3 3 4 4 5 0 0 0 0 0 0 I don't understand why there are three zeroes at the end. - reader.maxDoc is 5 and no documents have been deleted. - I have tried this with a varying number of documents and there are always three zeroes at the end. - I tried changing version to Lucene 4.10.0 and Lucene 4.9 and the same behavior occurs. I can work around this with but I'm just curious if this behavior is expected? Regards, Barry --089e0122aae240e38f05080fcaf9--