Return-Path: X-Original-To: apmail-lucene-java-user-archive@www.apache.org Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5DDBD1135C for ; Thu, 28 Aug 2014 21:33:47 +0000 (UTC) Received: (qmail 98279 invoked by uid 500); 28 Aug 2014 21:33:45 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 98209 invoked by uid 500); 28 Aug 2014 21:33:45 -0000 Mailing-List: contact java-user-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-user@lucene.apache.org Delivered-To: mailing list java-user@lucene.apache.org Received: (qmail 98197 invoked by uid 99); 28 Aug 2014 21:33:44 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 Aug 2014 21:33:44 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS,T_FILL_THIS_FORM_SHORT X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of rob.nikander@gmail.com designates 209.85.223.182 as permitted sender) Received: from [209.85.223.182] (HELO mail-ie0-f182.google.com) (209.85.223.182) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 Aug 2014 21:33:18 +0000 Received: by mail-ie0-f182.google.com with SMTP id rd18so1771399iec.13 for ; Thu, 28 Aug 2014 14:33:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=1+GnUD7NaBgEQSbC0cwRg7UPQdwGP2UUD3ht1HAtpo0=; b=ad+Lm4r4xDIvoyfHgeTos2icYg39SvYxP5RGIgx2FHbjw1ioQGz8ZTcNZek5ZiPYRz JNS0z7gUGXhYo/2YTOSbyrFmqqR86iOA6ovgyqfXtATmx+Cbx3M2kg9BYs+v05WQP9rI neMVmjyCULOBVgdK7zGeXIMWydCfTMyMppPG+9nWOWQPggiTHgS4fu2yw37b9N0hpqz4 JctptvVcasm5x3/AxLSU1Sj0pxkw2j+Gz5zv9xYV9VZyYmddUDKDwZPo0wTliXkO/RwF fIMLTj+R0yPrXVbL6LRc9VEDc5ds5oFD2U8fi1BBoGOFKOJCV0OHY3q4q5AbrPVgS5jt rEnQ== MIME-Version: 1.0 X-Received: by 10.50.43.233 with SMTP id z9mr22859924igl.41.1409261596650; Thu, 28 Aug 2014 14:33:16 -0700 (PDT) Received: by 10.64.15.226 with HTTP; Thu, 28 Aug 2014 14:33:16 -0700 (PDT) Date: Thu, 28 Aug 2014 17:33:16 -0400 Message-ID: Subject: Can I update one field in doc? From: Rob Nikander To: java-user@lucene.apache.org Content-Type: multipart/alternative; boundary=089e01227748dd33fd0501b748a3 X-Virus-Checked: Checked by ClamAV on apache.org --089e01227748dd33fd0501b748a3 Content-Type: text/plain; charset=UTF-8 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 --089e01227748dd33fd0501b748a3--