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-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org

Reply via email to