Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 22480 invoked from network); 20 Jan 2009 13:02:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 20 Jan 2009 13:02:56 -0000 Received: (qmail 93229 invoked by uid 500); 20 Jan 2009 13:02:49 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 93198 invoked by uid 500); 20 Jan 2009 13:02:49 -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 93182 invoked by uid 99); 20 Jan 2009 13:02:48 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Jan 2009 05:02:48 -0800 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of aminmc@gmail.com designates 209.85.200.169 as permitted sender) Received: from [209.85.200.169] (HELO wf-out-1314.google.com) (209.85.200.169) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Jan 2009 13:02:42 +0000 Received: by wf-out-1314.google.com with SMTP id 28so3233916wfc.20 for ; Tue, 20 Jan 2009 05:02:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=BDQv1BEcHvMmsVuo5OYkcc5IXoeVmg4QN8NIi1cTEEk=; b=jgbcHmC7XDe/5ymd8JGBhtdLvEg1bMad7Cg76B072JEteU7Y51a3fOFY/zt2xSXz+6 xB4t+bR74zpY9rVkuYXeXZmk8WWYxibqwQ5e9fd6RjYvsLzLrPH50HcZRWq8ome/wkkd u4wozmPGxEZo+LHoKhnIlQuviyOmsfBiu+ds4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=c4fQ9fnRFnIZvpSWQr7ZehlDXrwRo7/098E20cO2RMpPmv1po/X/PyGfpWstVx42gs JvcL0GEkXk+fPJc6btaGrMt7UNJV24wtUd564jznYe0IBW+LMCefjTXc/cp81NhB7tM1 7T1N9U/1YI4llfPzJ4FO+iBgXliHxckL6mOQA= MIME-Version: 1.0 Received: by 10.143.32.7 with SMTP id k7mr2870257wfj.162.1232456542031; Tue, 20 Jan 2009 05:02:22 -0800 (PST) In-Reply-To: <066101c97ae2$2cc008b0$710bc30a@sv.us.sonicwall.com> References: <14F458B4-99E1-481F-A737-7A0C18D33AE0@gmail.com> <7EA1FE7D-2910-474E-872A-402DCE53076E@gmail.com> <066101c97ae2$2cc008b0$710bc30a@sv.us.sonicwall.com> Date: Tue, 20 Jan 2009 13:02:21 +0000 Message-ID: <6f4104d80901200502m384a8591t706dfdb52ef73c2b@mail.gmail.com> Subject: Re: Indexing and Searching Web Application From: Amin Mohammed-Coleman To: java-user@lucene.apache.org Content-Type: multipart/alternative; boundary=00504502dd6c63901d0460e9a6b2 X-Virus-Checked: Checked by ClamAV on apache.org --00504502dd6c63901d0460e9a6b2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Am I supposed to close the oldIndexReader? I just tried this and I get an exception stating that the IndexReader is closed. Cheers On Tue, Jan 20, 2009 at 9:33 AM, Ganesh wrote: > Reopen the reader, only if it is modified. > > IndexReader oldIndexReader = indexSearcher.getIndexReader(); > if (!oldIndexReader.isCurrent()) { > IndexReader newIndexReader = oldIndexReader.reOpen(); > oldIndexReader.close(); > indexSearcher.close(); > IndexSearcher indexSearch = new IndexSearcher(newIndexReader); > } > > Regards > Ganesh > > ----- Original Message ----- From: "Amin Mohammed-Coleman" < > aminmc@gmail.com> > To: > Sent: Tuesday, January 20, 2009 1:38 PM > Subject: Re: Indexing and Searching Web Application > > > > Hi >> >> After your email I had a look around and came up with the below >> solution (I'm not sure if this is the right approach or there is a >> performance implication to doing this) >> >> public Summary[] search(SearchRequest searchRequest) { >> List summaryList = new ArrayList(); >> StopWatch stopWatch = new StopWatch("searchStopWatch"); >> stopWatch.start(); >> MultiSearcher multiSearcher = null; >> List newIndexSearchers = new >> ArrayList(); >> try { >> for (IndexSearcher indexSearcher: searchers) { >> IndexReader indexReader = indexSearcher.getIndexReader().reopen(); >> IndexSearcher indexSearch = new IndexSearcher(indexReader); >> newIndexSearchers.add(indexSearch); >> } >> >> multiSearcher = new MultiSearcher(newIndexSearchers.toArray(new >> IndexSearcher[] {})); >> QueryParser queryParser = new >> MultiFieldQueryParser(FieldNameEnum.fieldNameDescriptions(), analyzer); >> Query query = queryParser.parse(searchRequest.getSearchTerm()); >> >> //TODO: Sort and Filters >> >> TopDocs topDocs = multiSearcher.search(query, 100); >> ScoreDoc[] scoreDocs = topDocs.scoreDocs; >> LOGGER.debug("total number of hits for [" + query.toString() + " ] >> = " +topDocs.totalHits); >> >> for (ScoreDoc scoreDoc : scoreDocs) { >> final Document doc = multiSearcher.doc(scoreDoc.doc); >> float score = scoreDoc.score; >> final BaseDocument baseDocument = new BaseDocument(doc, score); >> Summary documentSummary = new DocumentSummaryImpl(baseDocument); >> summaryList.add(documentSummary); >> } >> >> } catch (Exception e) { >> throw new IllegalStateException(e); >> } >> >> stopWatch.stop(); >> >> LOGGER.debug("total time taken for seach: " + >> stopWatch.getTotalTimeMillis() + " ms"); >> return summaryList.toArray(new Summary[] {}); >> } >> >> >> The searchers are configured in spring using which looks like this: >> >> > class="org.apache.lucene.search.IndexSearcher" scope="prototype" lazy- >> init="true" > >> > ref="rtfDirectory" /> >> >> >> I set the dependencies on the DocumentSearcher class. >> >> >> Cheers >> Amin >> >> >> On 19 Jan 2009, at 21:45, Amin Mohammed-Coleman wrote: >> >> I make a call to my search class which looks like this: >>> >>> >>> public Summary[] search(SearchRequest searchRequest) { >>> List summaryList = new ArrayList(); >>> StopWatch stopWatch = new StopWatch("searchStopWatch"); >>> stopWatch.start(); >>> MultiSearcher multiSearcher = null; >>> try { >>> multiSearcher = new MultiSearcher(searchers.toArray(new >>> IndexSearcher[] {})); >>> QueryParser queryParser = new >>> MultiFieldQueryParser(FieldNameEnum.fieldNameDescriptions(), >>> analyzer); >>> Query query = queryParser.parse(searchRequest.getSearchTerm()); >>> >>> //TODO: Sort and Filters >>> >>> TopDocs topDocs = multiSearcher.search(query, 100); >>> ScoreDoc[] scoreDocs = topDocs.scoreDocs; >>> LOGGER.debug("total number of hits for [" + query.toString() + >>> " ] = " +topDocs.totalHits); >>> >>> for (ScoreDoc scoreDoc : scoreDocs) { >>> final Document doc = multiSearcher.doc(scoreDoc.doc); >>> float score = scoreDoc.score; >>> final BaseDocument baseDocument = new BaseDocument(doc, score); >>> Summary documentSummary = new DocumentSummaryImpl(baseDocument); >>> summaryList.add(documentSummary); >>> } >>> >>> } catch (Exception e) { >>> throw new IllegalStateException(e); >>> } >>> stopWatch.stop(); >>> >>> LOGGER.debug("total time taken for seach: " + >>> stopWatch.getTotalTimeMillis() + " ms"); >>> return summaryList.toArray(new Summary[] {}); >>> } >>> >>> Do I need to do this explicitly? >>> >>> >>> Cheers >>> Amin >>> >>> On 19 Jan 2009, at 20:48, Greg Shackles wrote: >>> >>> After you make the commit to the index, are you reloading the index >>>> in the >>>> searchers? >>>> >>>> - Greg >>>> >>>> >>>> On Mon, Jan 19, 2009 at 3:29 PM, Amin Mohammed-Coleman < >>>> aminmc@gmail.com >>>> >wrote: >>>> >>>> Hi >>>>> >>>>> I have recently worked on developing an application which allows >>>>> you to >>>>> upload a file (which is indexed so you can search later). I have >>>>> numerous >>>>> tests to show that you can index and search documents (in some >>>>> instances >>>>> within the same test), however when I perform the operation in the >>>>> site: >>>>> >>>>> 1) Upload File and Index >>>>> 2) Search >>>>> >>>>> I don't get any hits. When I restart the application then if I make >>>>> another search I can find the results. It seems as though indexes >>>>> aren't >>>>> being committed when I do the initial upload. This is strange. I >>>>> explicitly call commit in my code when I upload the file. Has >>>>> anyone >>>>> experienced this before? >>>>> >>>>> Any help would be appreciated. >>>>> >>>>> Kind Regards >>>>> >>>>> Amin >>>>> >>>>> --------------------------------------------------------------------- >>>>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org >>>>> For additional commands, e-mail: java-user-help@lucene.apache.org >>>>> >>>>> >>>>> >>> >> >> > Send instant messages to your online friends http://in.messenger.yahoo.com > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org > For additional commands, e-mail: java-user-help@lucene.apache.org > > --00504502dd6c63901d0460e9a6b2--