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 A8EA39E4F for ; Fri, 8 Jun 2012 10:42:17 +0000 (UTC) Received: (qmail 66249 invoked by uid 500); 8 Jun 2012 10:42:15 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 66080 invoked by uid 500); 8 Jun 2012 10:42:13 -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 66048 invoked by uid 99); 8 Jun 2012 10:42:11 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Jun 2012 10:42:11 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [93.104.200.132] (HELO echelon.iconparc.de) (93.104.200.132) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Jun 2012 10:42:05 +0000 Received: from [172.16.0.73] (hal7.local.iconparc.de [172.16.0.73]) by echelon.iconparc.de (Postfix) with ESMTP id C6D2E265BEA for ; Fri, 8 Jun 2012 12:41:43 +0200 (CEST) Message-ID: <4FD1D6E7.2050101@iconparc.de> Date: Fri, 08 Jun 2012 12:41:43 +0200 From: Christoph Kaser User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20120604 Thunderbird/13.0 MIME-Version: 1.0 To: java-user@lucene.apache.org Subject: Re: Nested indexing doubt. References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Hi Ananth, You have to add the child documents before the parent document, otherwise the blockjoinquery won't work. Regards, Christoph Am 08.06.2012 10:18, schrieb Ananth V: > Hey guys, > I'm trying to index nested documents in lucene 3.6. I have > the parent document having a 'type' and 'typename' fields and the children > having 'value' and 'author' fields. The below snippet is what i've written > to index them as a block. Is this correct? Is there any working piece of > code i can use. Googling wasn't helpful. > > private static void addDoc(IndexWriter w,String type, String > typename,String value, String author, String value2, String author2) throws > IOException { > ArrayList docs=new ArrayList(); > Document doc = new Document(); > doc.add(new Field("type", type, Field.Store.YES, Field.Index.ANALYZED)); > doc.add(new Field("typename", typename, Field.Store.YES, > Field.Index.ANALYZED)); > docs.add(doc); > Document doc1 = new Document(); > doc1.add(new Field("value", value, Field.Store.YES, > Field.Index.ANALYZED)); > doc1.add(new Field("author", author, Field.Store.YES, > Field.Index.ANALYZED)); > docs.add(doc1); > Document doc2 = new Document(); > doc2.add(new Field("value", value2, Field.Store.YES, > Field.Index.ANALYZED)); > doc2.add(new Field("author", author2, Field.Store.YES, > Field.Index.ANALYZED)); > docs.add(doc2); > w.addDocuments(docs); > } > > Thanks, > Ananth. > --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org