lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christoph Kaser <lucene_l...@iconparc.de>
Subject Re: Nested indexing doubt.
Date Fri, 08 Jun 2012 10:41:43 GMT
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<Document> docs=new ArrayList<Document>();
>      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


Mime
View raw message