Hi Chris, So doc.removeFields works fine, just tried it again. You could try using an approach on the lines of the one mentioned below.
*--snip--* IndexWriter iw = new IndexWriter(indexDir, new StandardAnalyzer(Version.LUCENE_30),true, MaxFieldLength.UNLIMITED); Document doc = new Document(); doc.add(getField(FIELD1, "aa")); doc.add(getField(FIELD1, "bb")); doc.add(getField(FIELD2, "cc")); iw.addDocument(doc); doc.removeFields("field1"); doc.add(getField(FIELD1, "aaa")); doc.add(getField(FIELD1, "bbb")); doc.add(getField(FIELD2, "ccc")); iw.addDocument(doc); IndexReader ir = iw.getReader(); IndexSearcher is = new IndexSearcher(ir); BooleanQuery query = new BooleanQuery(); query.add(new TermQuery(new Term("field1", "aa")), Occur.MUST); ScoreDoc[] sd = is.search(query, 10).scoreDocs; for(ScoreDoc scoreDoc:sd){ System.out.println(ir.document(scoreDoc.doc)); } is.close(); ir.close(); iw.close(); *--Snip--* -- Anshum Gupta http://ai-cafe.blogspot.com On Fri, Apr 15, 2011 at 6:32 AM, Christopher Condit <con...@sdsc.edu> wrote: > I know that it's best practice to reuse the Document object when > indexing, but I'm curious how multi-valued fields affect this. I tried > this before indexing each document: > > doc.removeFields(myMultiValuedField); > for (String fieldName: fieldNames) { > Field field= doc.getField(field); > if (null != field) { > field.setValue(""); > } else { > System.out.println("null field"); > } > } > > And it seems that the null fields (which I had removed) are just > accumulating. Is there a better way to reuse a document with > multi-valued fields? > > Thanks, > -Chris > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org > For additional commands, e-mail: java-user-h...@lucene.apache.org > >