Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id EAFF6200B33 for ; Wed, 15 Jun 2016 01:43:07 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id E962F160A56; Tue, 14 Jun 2016 23:43:07 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 3D1FA160A06 for ; Wed, 15 Jun 2016 01:43:07 +0200 (CEST) Received: (qmail 30301 invoked by uid 500); 14 Jun 2016 23:43:06 -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 30286 invoked by uid 99); 14 Jun 2016 23:43:05 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 14 Jun 2016 23:43:05 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 31973C0313 for ; Tue, 14 Jun 2016 23:43:05 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.121 X-Spam-Level: X-Spam-Status: No, score=-0.121 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=trypticon.org Received: from mx2-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id ik51S3nCpxLF for ; Tue, 14 Jun 2016 23:43:02 +0000 (UTC) Received: from mail-yw0-f180.google.com (mail-yw0-f180.google.com [209.85.161.180]) by mx2-lw-us.apache.org (ASF Mail Server at mx2-lw-us.apache.org) with ESMTPS id CF48160CD1 for ; Tue, 14 Jun 2016 23:43:01 +0000 (UTC) Received: by mail-yw0-f180.google.com with SMTP id v137so5590631ywa.3 for ; Tue, 14 Jun 2016 16:43:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=trypticon.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=75zb0JhjZfZi7ZZhNBcaJ8fntp07vruBuhuAboKsmzM=; b=E3L+44lgOwUGoWjoMoGjzPIWCcPdE1qZq1PhRO2f1FSy16H7Y6+eEqzbCGMAL1pdff ZPv4eEaOwgjlI60aWNntiPy/5LBbbWr7K0D48yDteSvsbjU+eoA6hxy2bYzCbhqlBqyv bK0nSmnRuR96/Tny1E/3FLpqqw6PSh1YnxUBOBmthPYAMkKpFq1ivNP1KaoOf/VDsfEl S4cbIMEINfEydsqqBt3fdkSxAKyxeU4eeYUbMp/Vic5Iadxa65ruYAIcse0el+HZWhiB Cw0rD8Y5JTGUIkaPYLnvR+gwFonBbBJ9egIMZPggWRFX1V7/Ha8sKwEp06HtzXTq/N82 5/vA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=75zb0JhjZfZi7ZZhNBcaJ8fntp07vruBuhuAboKsmzM=; b=mNVn4sYHgxCfSPTFcu9s0DUEe6av++3m3B7bqVnsIprSSGm7L1zUtZ3KIvtp15aR68 KKCUUvjds79iyWgRXEyNa+GnL1qMC1BRtX2lCGwCmu0GHMSRRiD2cwhQC8rNXf1O2xAf BZfNuyRBrSWFLWEVYhspZkEQLfXYTLxBVqHF1XK3/fr1ZEgtZcU/EIKgqI+bGAyXSXV1 Eo3p0k/sp1M++O6/qj9yaolQgB5FvjIGbBNQ5a3rOy3TL1DiBlUDQJ4IZy+o2A/FCpig g1KIe7HcaV6demdkTAjUTjLlSnnIM4ojEDrdzG/YnwImh/nnWfE4gGFnimWfVnZ1NFu5 f0/g== X-Gm-Message-State: ALyK8tJ01A6sBn5o02bTuNfSNXBzdU/+DSBD+KXLWaO0Jh81dQTMYjdNt87W6qNm1UQg+Q== X-Received: by 10.37.125.199 with SMTP id y190mr12536564ybc.173.1465947773651; Tue, 14 Jun 2016 16:42:53 -0700 (PDT) Received: from mail-yw0-f171.google.com (mail-yw0-f171.google.com. [209.85.161.171]) by smtp.gmail.com with ESMTPSA id i71sm8265634ywg.34.2016.06.14.16.42.52 for (version=TLSv1/SSLv3 cipher=OTHER); Tue, 14 Jun 2016 16:42:52 -0700 (PDT) Received: by mail-yw0-f171.google.com with SMTP id g20so5749417ywb.0 for ; Tue, 14 Jun 2016 16:42:52 -0700 (PDT) X-Received: by 10.37.83.131 with SMTP id h125mr12431156ybb.109.1465947772601; Tue, 14 Jun 2016 16:42:52 -0700 (PDT) MIME-Version: 1.0 Received: by 10.129.103.87 with HTTP; Tue, 14 Jun 2016 16:42:52 -0700 (PDT) In-Reply-To: References: From: Trejkaz Date: Wed, 15 Jun 2016 09:42:52 +1000 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: How to get the index for a document after a search over multiple indexes To: Lucene Users Mailing List Content-Type: text/plain; charset=UTF-8 archived-at: Tue, 14 Jun 2016 23:43:08 -0000 On Wed, Jun 15, 2016 at 6:08 AM, Mark Shapiro wrote: > private static IndexSearcher getSearcher( String[] indexDirs ) throws Exception { > IndexReader[] readers = new IndexReader[indexDirs.length]; > FSDirectory[] directorys = new FSDirectory[indexDirs.length]; > > for ( int i = 0; i < indexDirs.length; ++i ) { > File file = new File( indexDirs[i] ); > directorys[i] = ( bWindows ) ? new MMapDirectory( file ) : new NIOFSDirectory( file ); > directorys[i].setReadChunkSize( Integer.MAX_VALUE ); > readers[i] = IndexReader.open( directorys[i], true ); > } > > MultiReader multiReader = new MultiReader( readers, true ); > IndexSearcher searcher = new IndexSearcher( multiReader, executorService ); // ExecutorService > return searcher; > } OK, so if you want to retrieve the Document, you can call document(int) on this multiReader and it will automatically take care of retrieving it from the right underlying reader. If you want to do it manually, you can keep around the IndexReader[] and binary search on it to figure out which one contains the doc ID. Or you can build an int[] of the starting doc IDs for each reader and use ReaderUtil.subIndex to compute it probably more efficiently. This is what composite readers use to do the same thing internally. TX --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org