I used the "Luke" tool to look at my documents. It shows that the positions and offsets in the term vectors get wiped out, in all fields. I'm using Lucene 4.8. I guess I'll just rebuild the entire doc.
Rob On Thu, Aug 28, 2014 at 5:33 PM, Rob Nikander <rob.nikan...@gmail.com> wrote: > I tried something like this, to loop through all docs in my index and > patch a field. But it appears to wipe out some parts of the stored values > in the document. For example, highlighting stopped working. > > [ scala code ] > val q = new MatchAllDocsQuery() > val topDocs = searcher.search(q, 1000000) > val field = new StringField(FieldNames.phone, "", Field.Store.YES) > > for (sdoc <- topDocs.scoreDocs) { > val doc = searcher.doc(sdoc.doc) > val id = doc.get(FieldNames.id) > var phone = doc.get(FieldNames.phone) > phone = phone + " changed" > doc.removeField(FieldNames.phone) > field.setStringValue(searchable) > doc.add(field) > writer.updateDocument(new Term(FieldNames.id, id), doc) > } > > Should it work? The documents have many fields and it takes 35 minutes to > rebuild the index from scratch. I'd like to be able to run smaller "patch" > tasks like this. > > Rob >