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 B41F9E443 for ; Wed, 6 Feb 2013 19:32:35 +0000 (UTC) Received: (qmail 90950 invoked by uid 500); 6 Feb 2013 19:32:33 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 90901 invoked by uid 500); 6 Feb 2013 19:32:33 -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 90892 invoked by uid 99); 6 Feb 2013 19:32:33 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Feb 2013 19:32:33 +0000 X-ASF-Spam-Status: No, hits=0.3 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_SOFTFAIL X-Spam-Check-By: apache.org Received-SPF: softfail (nike.apache.org: transitioning domain of jon@lightboxtechnologies.com does not designate 209.85.212.177 as permitted sender) Received: from [209.85.212.177] (HELO mail-wi0-f177.google.com) (209.85.212.177) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Feb 2013 19:32:26 +0000 Received: by mail-wi0-f177.google.com with SMTP id hm14so1992895wib.16 for ; Wed, 06 Feb 2013 11:32:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lightboxtechnologies.com; s=google; h=mime-version:x-received:x-originating-ip:date:message-id:subject :from:to:content-type; bh=QbiscCMyIBGHIZA/3XsJuWhUeILntDD27wj7khUA/Kk=; b=drn1/UNPwSlrAdWaOOPgmEpsuZai1PkezYx/jNokC3ftmNLQhjsr5yceXh2YY+So/g k4Eb5FYnn6p4MtIqUmvVEEi1dmE85t95AwxLolM4Lz/3GaylIPZO4Ch9uBSCLZXJs3KN kncDHD6U2iPgViNCJe+O1aEleVA9zz4oPK59g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:x-originating-ip:date:message-id:subject :from:to:content-type:x-gm-message-state; bh=QbiscCMyIBGHIZA/3XsJuWhUeILntDD27wj7khUA/Kk=; b=c78YLAxSkc6k2AVM4SoVWJ5uzvLSAfBVy3pzWYw0c8ZcfVMuKXIT837jM6UzyxLbv5 4nkysSbhcIh0nzqjs0rp+o3sVlImSrrWqakVBCTZUPeztHqffvwF15fluDWRck4f4M7H NnvsIJSxDM1Wh6r2LTnHG6n7yUuWV5nciqcBQ9bqe3VrYXX/Wih82gp7NOJVPWMX7YKY PCc3d29YC1tSClk5xHlJfsIZ372Q9YkI8n8nVyOIIS/gO5Coix2DzqmoY3lZziCRsRlK xTD2O6onldo6Mpw6fs2Fckc3WMOwsXsQNta5nwvt2IbKALGoskFltiHZU7hwmKa1Xh9q pctg== MIME-Version: 1.0 X-Received: by 10.194.216.66 with SMTP id oo2mr52027576wjc.4.1360179124234; Wed, 06 Feb 2013 11:32:04 -0800 (PST) Received: by 10.216.235.65 with HTTP; Wed, 6 Feb 2013 11:32:04 -0800 (PST) X-Originating-IP: [68.33.9.116] Date: Wed, 6 Feb 2013 14:32:04 -0500 Message-ID: Subject: testing whether a field has terms before adding document to Index From: Jon Stewart To: java-user@lucene.apache.org Content-Type: text/plain; charset=UTF-8 X-Gm-Message-State: ALoCoQmRt2cPUmrqZOOSVFNeaEqJM1VD7ud67RdSYYbsQnacen4jf9ZsCbTzOwuA71prdTGuWiK0 X-Virus-Checked: Checked by ClamAV on apache.org Hello, I have an application where a great many documents may not have any terms after StandardAnalyzer has had its way with the body. In that case, depending on some other metadata, I may not wish to add the document to the index altogether. Is there a way to tell? i.e., current I'm doing this: Document doc = new Document(); doc.addField(new Field("body", bodyString, INDEXED | etc)); MyIndexWriter.add(doc); and I'd like to do this: Field body = new Field("body", bodyString, INDEXED | etc); if (body has terms post-analysis) { Document doc = new Document(); doc.addField(body); MyIndexWriter.add(doc); } Is it possible to do this? I don't mind jumping through some hoops. Thanks! Jon -- Jon Stewart, Principal (646) 719-0317 | jon@lightboxtechnologies.com | Arlington, VA --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org