You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Rushikesh Garadade <ru...@gmail.com> on 2018/06/19 13:03:54 UTC

Retrieving Results from both child and parent

Hello,
I have stored emails in solr, with its attachments as child documents.
As per solr structure these attachments got stored in same lines as of
mails.
Ex:
{ "id":"1528801242887_f662e5fe-b5d7-4494-acab-c1a99e6cd025", "attachmentName
":"example_multipage.doc", "attachmentType":"application/msword", "_version_
":1603064318599888896}, { "id":"1528801242887", "internetMessageId":
"1528801242887", "mailboxMessageId":"MailBox_4", "from":"
miturria@verizon.net", "to":["podmaster@live.com"], "cc":["gslondon@aol.com"
], "bcc":["noticias@msn.com", "bester@gmail.com"], "subject":"Getting
Started", "mailBody":"\n\nGoogle's headquarters, the Googleplex, in August
2014\n ", "mailReceiveDate":"2018-05-07T12:33:51Z", "hasAttachment":true, "
_version_":1603064318599888896}

}

Now I want to perform search. What will be search query for:

I want to search a keyword everywhere and return the respective
"internetMessageId".
i.e.
#1 if word found in mail document -- return internetMessageId
#2 if word found in attachment document document -- return internetMessageId
(By fq==>{!parent which=internetMessageId:* v=attachmentName:*})

For achieving both i have store every fields content in "_text_" field
(using copy field) . I can achieve both #1 & #2 individually. I want to do
both in single result i.e give me internetMessageId of all mails as well as
the mails whose attachment contains the the queried word.


How can I achieve this??


Thanks,
Rushikesh Garadade

Re: Retrieving Results from both child and parent

Posted by Rushikesh Garadade <ru...@gmail.com>.
I found one solution, however i am not sure whether this is
optimized/corrct solution to it.

Return a mails which contains a word 'pdf' anywhere  : *({!parent
which=internetMessageId:* v=pdf}) OR (internetMessageId:* AND pdf)*
a) ({!parent which=internetMessageId:* v=pdf}) ==> return mails whose
attachment has the keyword 'pdf'
b) (internetMessageId:* AND pdf) ==> returns only mails which contains the
word 'pdf'

Solr identify mail document with *internetMessageId:* *as this field is not
present in attachment document


Please let me know if this is right approch/way to query such results or *Is
there any better/optimized approach*

Thanks,
Rushikesh Garadade

On Tue, Jun 19, 2018 at 6:33 PM Rushikesh Garadade <
rushikeshgaradade@gmail.com> wrote:

> Hello,
> I have stored emails in solr, with its attachments as child documents.
> As per solr structure these attachments got stored in same lines as of
> mails.
> Ex:
> { "id":"1528801242887_f662e5fe-b5d7-4494-acab-c1a99e6cd025", "
> attachmentName":"example_multipage.doc", "attachmentType":
> "application/msword", "_version_":1603064318599888896}, { "id":
> "1528801242887", "internetMessageId":"1528801242887", "mailboxMessageId":
> "MailBox_4", "from":"miturria@verizon.net", "to":["podmaster@live.com"], "
> cc":["gslondon@aol.com"], "bcc":["noticias@msn.com", "bester@gmail.com"],
> "subject":"Getting Started", "mailBody":"\n\nGoogle's headquarters, the
> Googleplex, in August 2014\n ", "mailReceiveDate":"2018-05-07T12:33:51Z",
> "hasAttachment":true, "_version_":1603064318599888896}
>
> }
>
> Now I want to perform search. What will be search query for:
>
> I want to search a keyword everywhere and return the respective "internetMessageId".
> i.e.
> #1 if word found in mail document -- return internetMessageId
> #2 if word found in attachment document document -- return internetMessageId
> (By fq==>{!parent which=internetMessageId:* v=attachmentName:*})
>
> For achieving both i have store every fields content in "_text_" field
> (using copy field) . I can achieve both #1 & #2 individually. I want to do
> both in single result i.e give me internetMessageId of all mails as well
> as the mails whose attachment contains the the queried word.
>
>
> How can I achieve this??
>
>
> Thanks,
> Rushikesh Garadade
>
>