lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rob Nikander <rob.nikan...@gmail.com>
Subject Can I update one field in doc?
Date Thu, 28 Aug 2014 21:33:16 GMT
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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message