Hello All,
I am working on Parent-Child document in my current project. I want to
fetch parent documents and child documents with its parent document if
child documents satisfy search term.
Following is my current scenario and my questions.
Parent Document Mapping
Parent Document Name
Authors
Fields
AuthorCode
AuthorName
Parent Document Data
Id
AuthorName
1
John
2
Marry
3
Waulter
Child Document Mapping
Child Document Name
Book
Fields
BookName
Genre
Publisher
Child Document Data
ParentId/AuthorId
ChildId
BookName
Genre
Publisher
1
1
MerryChristmas
Family
McGrow
2
2
Johncarter
Adventure
Deitel
2
3
Java Bible
Programming
BPB
3
4
How to play flute
Self Study
Johnson
Now from above parent and child data, I would like to search term which is
start with “john”. So I would expect following output. Please note that I
would expect parent who satisfy search term and child (with ITS PARENT) who
satisfy search term. Following should be expected output. Last column of
following result explain why particular document does appear in search
result.
AuthorName
BookName
Genre
Publisher
Reason to display in result
John
N/A
N/A
N/A
Author name start with John(only parent doc will return)
Marry
Johncarter
Adventure
Deitel
Bookname start with John(Parent doc along with child doc return)
Waulter
flute
Self Study
Johnson
Publisher start with John(Parent doc along with child doc return)
So my question is How can we write query that return parent and child with
its parent?
Thank you?
--