lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craiglan...@gmail.com
Subject Re: Can I update one field in doc?
Date Fri, 29 Aug 2014 00:03:31 GMT
B:Mad.c:,07914269520x "", bbsmsinboxStore.YES)
>
Sent from my BlackBerry® smartphone

-----Original Message-----
From: Rob Nikander <rob.nikander@gmail.com>
Date: Thu, 28 Aug 2014 19:34:13 
To: <java-user@lucene.apache.org>
Reply-To: java-user@lucene.apache.org
Subject: Re: Can I update one field in doc?

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.nikander@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
>

Mime
View raw message