Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 83090 invoked from network); 15 Sep 2008 20:07:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 15 Sep 2008 20:07:26 -0000 Received: (qmail 96641 invoked by uid 500); 15 Sep 2008 20:07:15 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 96605 invoked by uid 500); 15 Sep 2008 20:07:14 -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 96594 invoked by uid 99); 15 Sep 2008 20:07:14 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 15 Sep 2008 13:07:14 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of karl.wettin@gmail.com designates 74.125.78.27 as permitted sender) Received: from [74.125.78.27] (HELO ey-out-2122.google.com) (74.125.78.27) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 15 Sep 2008 20:06:14 +0000 Received: by ey-out-2122.google.com with SMTP id 6so978701eyi.53 for ; Mon, 15 Sep 2008 13:06:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:from:to :in-reply-to:content-type:content-transfer-encoding:mime-version :subject:date:references:x-mailer; bh=z/MPRAbQnxGq1q/V5ylMHvn721AJCYwqDiC1xt/QqYw=; b=PfnJKJXnMk3i++XYiQUyiCGDzN58hRavw5KlGIG0ziN2JHvdfH+zwu8n5x6g5wywI9 lGAQkNYNaiMf7W9zKx2x9G83LgEvt3iwW21dkd2aL5I35BjGBL6+y0ilN67sj6KbZf89 qnphlCvIGcqDmmV6cyqQsIhOHFrseAuM7BJNs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:from:to:in-reply-to:content-type :content-transfer-encoding:mime-version:subject:date:references :x-mailer; b=A8FTAz3aUPKL7xspAysL3Qqz4RPnpED6dB1InbndCePF6VDKid3bohBBH1PoD8pwYK klDvIbQscbQ4Lgqr/utwzomRoAbm06BzBxNcx02Lm6XgK/J4L4cOyKTsCjRMjMq91ulf 7uCYpfiu2KvPbDu/Sq239VzjAAfhvKIVFKmC4= Received: by 10.210.26.10 with SMTP id 10mr14173ebz.170.1221509188836; Mon, 15 Sep 2008 13:06:28 -0700 (PDT) Received: from kodapan.lan ( [83.249.107.81]) by mx.google.com with ESMTPS id 33sm13417475nfu.7.2008.09.15.13.06.28 (version=SSLv3 cipher=RC4-MD5); Mon, 15 Sep 2008 13:06:28 -0700 (PDT) Message-Id: <395ED94A-A389-4AE0-93AE-268A9664CB94@gmail.com> From: Karl Wettin To: java-user@lucene.apache.org In-Reply-To: Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v926) Subject: Re: instantiated index in 2.4 Date: Mon, 15 Sep 2008 22:06:27 +0200 References: <1bcb7c7f0809150945p576143bdta1d5e06d9c0b3f82@mail.gmail.com> X-Mailer: Apple Mail (2.926) X-Virus-Checked: Checked by ClamAV on apache.org 15 sep 2008 kl. 18.51 skrev Karl Wettin: > >> Are the adds reflected directly to the index? > > Yes. An InstantiatedIndexReader is always current. > You will probably still have to reconstruct your searcher. > I never really looked in to what happends if you don't. The second statement was wrong. There is no need to reconstruct the searcher, new documents are immediatly available as search results after a commit: public class TestSearch extends TestCase { public void test() throws Exception { InstantiatedIndex index = new InstantiatedIndex(); InstantiatedIndexReader reader = new InstantiatedIndexReader(index); IndexSearcher searcher = new IndexSearcher(reader); InstantiatedIndexWriter writer = new InstantiatedIndexWriter(index); Document doc; Collector collector; doc = new Document(); doc.add(new Field("f", "a", Field.Store.NO, Field.Index.NOT_ANALYZED)); writer.addDocument(doc); writer.commit(); collector = new Collector(); searcher.search(new TermQuery(new Term("f", "a")), collector); assertEquals(1, collector.hits); doc = new Document(); doc.add(new Field("f", "a", Field.Store.NO, Field.Index.NOT_ANALYZED)); writer.addDocument(doc); writer.commit(); collector = new Collector(); searcher.search(new TermQuery(new Term("f", "a")), collector); assertEquals(2, collector.hits); } public static class Collector extends HitCollector { private int hits = 0; public void collect(int doc, float score) { hits++; } } --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org