Return-Path: Delivered-To: apmail-jakarta-lucene-user-archive@www.apache.org Received: (qmail 25892 invoked from network); 6 Dec 2004 14:46:29 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 6 Dec 2004 14:46:29 -0000 Received: (qmail 97727 invoked by uid 500); 6 Dec 2004 14:45:13 -0000 Delivered-To: apmail-jakarta-lucene-user-archive@jakarta.apache.org Received: (qmail 97451 invoked by uid 500); 6 Dec 2004 14:45:08 -0000 Mailing-List: contact lucene-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Lucene Users List" Reply-To: "Lucene Users List" Delivered-To: mailing list lucene-user@jakarta.apache.org Received: (qmail 97383 invoked by uid 99); 6 Dec 2004 14:45:07 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=FORGED_RCVD_HELO X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from fluffy.torchboxapps.com (HELO fluffy.torchbox.com) (81.187.40.70) by apache.org (qpsmtpd/0.28) with ESMTP; Mon, 06 Dec 2004 06:45:03 -0800 Received: from adsl.internal.torchbox.com ([192.168.1.3] helo=torchbox.com) by fluffy.torchbox.com with esmtp (Exim 4.34) id 1CbK6l-0000Lb-P6 for lucene-user@jakarta.apache.org; Mon, 06 Dec 2004 14:45:00 +0000 Date: Mon, 6 Dec 2004 14:45:01 +0000 Mime-Version: 1.0 (Apple Message framework v553) Content-Type: text/plain; charset=US-ASCII; format=flowed Subject: indexReader close method From: Helen Warren To: lucene-user@jakarta.apache.org Content-Transfer-Encoding: 7bit Message-Id: <68E2D155-4795-11D9-B435-000A958AF010@torchbox.com> X-Mailer: Apple Mail (2.553) X-Spam-Score: -104.6 (---------------------------------------------------) X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Hi All, I'm having some trouble closing an index reader. I'm getting a IOException (bad file descriptor). Can anybody tell me what I'm doing wrong and how I should be closing this object? An outline of an extract of my code: // Make a new searcher (indexName passed in as string). IndexReader myReader = IndexReader.open(indexName); searcher = new IndexSearcher(myReader); //Create a snowball analyzer object. //Create a MultifieldQueryParser object with the snowball analyzer and build a luceneQuery from a user entered search string. //Create a new BooleanQuery (overallQuery), add the luceneQuery to it and add several other BooleanQueries specific to other fields in the documents. // Do the search hits = searcher.search(overallQuery); //close the IndexSearcher object searcher.close(); //close the IndexReader object myReader.close(); //return results return hits; The myReader.close() line causes the IOException to be thrown. To try to debug, I wrote a simplified code to open and close a reader and searcher, and in the process discovered something else that I have found confusing: Here's an extract of the simplified code: String indexName = "foo"; // Make a new searcher IndexReader myReader = IndexReader.open(indexName); IndexSearcher searcher = new IndexSearcher(myReader); //try to do something with the reader Collection theseFields = myReader.getFieldNames(); //close the IndexSearcher object searcher.close(); //try to close the reader now myReader.close(); //now try to do something with the reader again; try { int maximum = myReader.maxDoc(); System.err.println("Next document would be: "+maximum); } catch (Exception e) { System.err.println("Exception: "+e.getMessage()); } In this case, the reader appears to close without error but even after I've called myReader.close() I can execute the maxDoc() method on that object and return results. Anybody shed any light? Thanks, Helen. --------------------------------------------------------------------- To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: lucene-user-help@jakarta.apache.org