srinivas, Create your IndexWriter and Analyzer once before your loop. I suggest you follow up any questions to the 'java-user' list.
Peter On Thu, 21 Feb 2008 13:14:21 -00, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > In the Following Code if i insert one document i was > able to delete but when i insert multiple documents i > was unable to delete. > > please follow the code and advice me > > thanks > srinvias. > > > > // Code to index Documents > for (int count = 1; count < 10; count++) > { > String CatID = "13"; > String FieldName = "Field-" + count; > > document.add(Field.Text("FieldName", > FieldName)); > document.add(Field.Keyword("CatID", > CatID)); > Analyzer analyzer = new > StandardAnalyzer(); > IndexWriter writer = new > IndexWriter(indexDirectory, analyzer, false); > writer.addDocument(document); > writer.optimize(); > writer.close(); > } > > //Code to delete Documents > Hits objhits = null; > IndexSearcher is = new > IndexSearcher(LuceneHandle.indexFields); > Analyzer analyzer = new StandardAnalyzer(); > QueryParser parser = new > QueryParser("CatID", analyzer); > Query query = parser.parse("13"); > objhits = is.search(query); > > IndexReader ir = > IndexReader.open(LuceneHandle.indexFields); > for(int i=0;i<objhits.length();i++) > { > Document doc = objhits.doc(i); > > String [] strtemp = > doc.getValues("CatID"); > > if(strtemp!=null) > for(int tempcount > =0;tempcount<strtemp.length;tempcount++) > { > Term uidTerm = new Term("CatID", > "13"); > int DelCount = ir.delete(uidTerm); > } > } > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >