and how do you do that? There is no reopen method On Tue, Jul 5, 2011 at 8:09 PM, Michael McCandless < luc...@mikemccandless.com> wrote:
> After your writer.commit you need to reopen your searcher to see the > changes. > > Mike McCandless > > http://blog.mikemccandless.com > > On Tue, Jul 5, 2011 at 1:48 PM, Gabriele Kahlout > <gabri...@mysimpatico.com> wrote: > > @Test > > public void testUpdate() throws IOException, > > ParserConfigurationException, SAXException, ParseException { > > Analyzer analyzer = getAnalyzer(); > > QueryParser parser = new QueryParser(Version.LUCENE_32, content, > > analyzer); > > Query allQ = parser.parse("*:*"); > > > > IndexWriter writer = getWriter(); > > IndexSearcher searcher = new > IndexSearcher(IndexReader.open(writer, > > true)); > > TopDocs docs = searcher.search(allQ, 10); > > * assertEquals(0, docs.totalHits); // empty/no index* > > > > Document doc = getDoc(); > > writer.addDocument(doc); > > writer.commit(); > > > > docs = searcher.search(allQ, 10); > > * assertEquals(1,docs.totalHits); //it fails here. docs.totalHits > > equals 0* > > } > > What am I doing wrong here? > > > > If I initialize searcher with new IndexSearcher(directory) I'm told: > > org.apache.lucene.index.IndexNotFoundException: no segments* file found > in > > org.apache.lucene.store.RAMDirectory@3caa4blockFactory > =org.apache.lucene.store.SingleInstanceLockFactory@ed0220c: > > files: [] > > > > -- > > Regards, > > K. Gabriele > > > > --- unchanged since 20/9/10 --- > > P.S. If the subject contains "[LON]" or the addressee acknowledges the > > receipt within 48 hours then I don't resend the email. > > subject(this) ∈ L(LON*) ∨ ∃x. (x ∈ MyInbox ∧ Acknowledges(x, this) ∧ > time(x) > > < Now + 48h) ⇒ ¬resend(I, this). > > > > If an email is sent by a sender that is not a trusted contact or the > email > > does not contain a valid code then the email is not received. A valid > code > > starts with a hyphen and ends with "X". > > ∀x. x ∈ MyInbox ⇒ from(x) ∈ MySafeSenderList ∨ (∃y. y ∈ subject(x) ∧ y ∈ > > L(-[a-z]+[0-9]X)). > > > -- Regards, K. Gabriele --- unchanged since 20/9/10 --- P.S. If the subject contains "[LON]" or the addressee acknowledges the receipt within 48 hours then I don't resend the email. subject(this) ∈ L(LON*) ∨ ∃x. (x ∈ MyInbox ∧ Acknowledges(x, this) ∧ time(x) < Now + 48h) ⇒ ¬resend(I, this). If an email is sent by a sender that is not a trusted contact or the email does not contain a valid code then the email is not received. A valid code starts with a hyphen and ends with "X". ∀x. x ∈ MyInbox ⇒ from(x) ∈ MySafeSenderList ∨ (∃y. y ∈ subject(x) ∧ y ∈ L(-[a-z]+[0-9]X)).