lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dan Climan" <dcli...@keepmedia.com>
Subject RE: INDEXREADER + DELETE + LUCENE1.4.1
Date Fri, 05 Nov 2004 18:02:09 GMT
I think you need to change
indexReader.delete(k);
to 
indexReader.delete(hits.id(k));

Dan
-----Original Message-----
From: Karthik N S [mailto:karthik@controlnet.co.in] 
Sent: Thursday, November 04, 2004 11:47 PM
To: LUCENE
Subject: INDEXREADER + DELETE + LUCENE1.4.1





Hi Guy's

Apologies............



There seems to be a bug unresolved [ Or may I be may be doing something
wrong ] in IndexReader.delete(int docNum)

Here is the Code

indexSearcher = null;
indexDirectory = null;
indexReader = null;
indexDirectory
=FSDirectory.getDirectory("/root/MERGEDINDEX/MERGER_1",false);
indexReader = IndexReader.open(indexDirectory);

IndexReader.unlock(indexDirectory);
indexSearcher = new IndexSearcher(indexReader);
query = new TermQuery(new Term(fieldName, FiledValue));
hits = indexSearcher.search(query);


if ( hits.length() > 0 ) {

for(int k=0;k<=hits.length();k++) {
PRINTDBG_.append("QUERY : " + query.toString() + "\n" +
                                    "FIELD NAME : " + fieldName + "\n" +
                                    "FIELD VALUE: " + FiledValue + "\n" +
                                    "TOTAL HITS : " + hits.length() + "\n" +
                                    "DELETING : " + k);

    indexReader.delete(k);

    }
}

indexReader.close();
indexSearcher.close();
indexDirectory.close();

System.out.printl(" Debugger : " +PRINTDBG_);
indexReader = null;
indexSearcher = null;
indexDirectory = null;

//optimization
indexDirectory = FSDirectory.getDirectory(pathMergeIndex,false);
IndexWriter writer = new IndexWriter(indexDirectory, analyzer, false);
writer.mergeFactor = mergeFactorVal_; writer.maxMergeDocs =
maxMergeDocsVal_; writer.optimize(); writer.close();

indexDirectory = null;
writer = null;

In spite of Using a new IndexReader for every Deletion of documents and
Optimization's The 'indexReader.delete(k)' does not seems to work

Configuration History

a) 1 MergerIndex = 1000 subIndexes [ fieldName = KeyWord Field Type]

b) O/s Windows

c) Amd Processor

e) Lucene 1.4.1

f) Jdk 1.4.2

Please Some body Suggest me For Alternates ........



      WITH WARM REGARDS
      HAVE A NICE DAY
      [ N.S.KARTHIK]





---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Mime
View raw message