lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ananth V <ananth1...@gmail.com>
Subject Nested indexing doubt.
Date Fri, 08 Jun 2012 08:18:33 GMT
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.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message