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 "Edwards, Joshua" <Jo...@capitalone.com> on 2014/10/08 17:54:19 UTC

Using Velocity with Child Documents?

Hi -

I am trying to index a collection that has child documents.  I have successfully loaded the data into my index using SolrJ, and I have verified that I can search correctly using the "child of" method in my fq variable.  Now, I would like to use Velocity (Solritas) to display the parent records with some details of the child records underneath.  Is there an easy way to do this?  Is there an example somewhere that I can look at?

Thanks,
Josh Edwards
________________________________________________________

The information contained in this e-mail is confidential and/or proprietary to Capital One and/or its affiliates. The information transmitted herewith is intended only for use by the individual or entity to which it is addressed.  If the reader of this message is not the intended recipient, you are hereby notified that any review, retransmission, dissemination, distribution, copying or other use of, or taking of any action in reliance upon this information is strictly prohibited. If you have received this communication in error, please contact the sender and delete the material from your computer.

Re: Using Velocity with Child Documents?

Posted by Chris Hostetter <ho...@fucit.org>.
: I am trying to index a collection that has child documents.  I have 
: successfully loaded the data into my index using SolrJ, and I have 
: verified that I can search correctly using the "child of" method in my 
: fq variable.  Now, I would like to use Velocity (Solritas) to display 
: the parent records with some details of the child records underneath.  
: Is there an easy way to do this?  Is there an example somewhere that I 
: can look at?

Step #1 is to forget about velocity and focus on getting the data you want 
about the children into the response.  

To do that you'll need to use the [child] DocTransformer...

https://cwiki.apache.org/confluence/display/solr/Transforming+Result+Documents

ala...

fl=id,[child parentFilter=doc_type:book childFilter=doc_type:chapter limit=100]

If you are using this in conjunction with a block join query, you can use 
local params to eliminate some redundency...

q=some_parent_field:foo
parents=content_type:parentDoc
fq={!parent which=$parents}child_field:bar
fl=id,[child parentFilter=$parents childFilter=content_type:childDoc limit=100]


Step #2: once you have the children in the response data, then you can use 
velocity to access each of the children of the docs that match your query 
via SolrDocument.getChildDocuments()



-Hoss
http://www.lucidworks.com/

RE: Using Velocity with Child Documents?

Posted by "Edwards, Joshua" <Jo...@capitalone.com>.
I just realized that Solr supports returning child records with the parent starting in version 4.9.  I was on 4.8, so I will be upgrading to latest before continuing on this.  I think it will then make it easier to show the results in Velocity (in case anyone else needs to do this).

Thanks,
Josh Edwards

-----Original Message-----
From: Edwards, Joshua [mailto:Joshua.Edwards@capitalone.com] 
Sent: Thursday, October 09, 2014 9:18 AM
To: solr-user@lucene.apache.org
Subject: RE: Using Velocity with Child Documents?

Hey, Erick -

Thanks for the response.  Yes, I've played around with Velocity before, and I've been able to get some good results.  However, with how Solr stores (and returns) child documents, I don't know of a way to get a response that is similar to the initial Json going in - with each parent document having the child documents underneath.  I believe that I have to get the parent information, and then run another query for each record to get the child records.  I didn't know if someone had done something similar.

Thanks,
Josh Edwards

-----Original Message-----
From: Erick Erickson [mailto:erickerickson@gmail.com] 
Sent: Wednesday, October 08, 2014 3:10 PM
To: solr-user@lucene.apache.org
Subject: Re: Using Velocity with Child Documents?

Velocity is just taking the Solr response and displaying selected bits in HTML. So assuming the information you want is in the reponse packet (which you can tell just by doing the query from the browser) it's "just" a matter of pulling it out of the response and displaying it.

Mostly when I started down this path I poked around the velocity directory it was just a bit of hunt int to figure things out, with some help from the Apache Velocity page.

Not much help, but the short form is there's much of an example that I know of for your specific problem.

Erick

On Wed, Oct 8, 2014 at 8:54 AM, Edwards, Joshua <Jo...@capitalone.com> wrote:
> Hi -
>
> I am trying to index a collection that has child documents.  I have successfully loaded the data into my index using SolrJ, and I have verified that I can search correctly using the "child of" method in my fq variable.  Now, I would like to use Velocity (Solritas) to display the parent records with some details of the child records underneath.  Is there an easy way to do this?  Is there an example somewhere that I can look at?
>
> Thanks,
> Josh Edwards
> ________________________________________________________
>
> The information contained in this e-mail is confidential and/or proprietary to Capital One and/or its affiliates. The information transmitted herewith is intended only for use by the individual or entity to which it is addressed.  If the reader of this message is not the intended recipient, you are hereby notified that any review, retransmission, dissemination, distribution, copying or other use of, or taking of any action in reliance upon this information is strictly prohibited. If you have received this communication in error, please contact the sender and delete the material from your computer.
________________________________________________________

The information contained in this e-mail is confidential and/or proprietary to Capital One and/or its affiliates. The information transmitted herewith is intended only for use by the individual or entity to which it is addressed.  If the reader of this message is not the intended recipient, you are hereby notified that any review, retransmission, dissemination, distribution, copying or other use of, or taking of any action in reliance upon this information is strictly prohibited. If you have received this communication in error, please contact the sender and delete the material from your computer.
________________________________________________________

The information contained in this e-mail is confidential and/or proprietary to Capital One and/or its affiliates. The information transmitted herewith is intended only for use by the individual or entity to which it is addressed.  If the reader of this message is not the intended recipient, you are hereby notified that any review, retransmission, dissemination, distribution, copying or other use of, or taking of any action in reliance upon this information is strictly prohibited. If you have received this communication in error, please contact the sender and delete the material from your computer.

RE: Using Velocity with Child Documents?

Posted by "Edwards, Joshua" <Jo...@capitalone.com>.
Hey, Erick -

Thanks for the response.  Yes, I've played around with Velocity before, and I've been able to get some good results.  However, with how Solr stores (and returns) child documents, I don't know of a way to get a response that is similar to the initial Json going in - with each parent document having the child documents underneath.  I believe that I have to get the parent information, and then run another query for each record to get the child records.  I didn't know if someone had done something similar.

Thanks,
Josh Edwards

-----Original Message-----
From: Erick Erickson [mailto:erickerickson@gmail.com] 
Sent: Wednesday, October 08, 2014 3:10 PM
To: solr-user@lucene.apache.org
Subject: Re: Using Velocity with Child Documents?

Velocity is just taking the Solr response and displaying selected bits in HTML. So assuming the information you want is in the reponse packet (which you can tell just by doing the query from the browser) it's "just" a matter of pulling it out of the response and displaying it.

Mostly when I started down this path I poked around the velocity directory it was just a bit of hunt int to figure things out, with some help from the Apache Velocity page.

Not much help, but the short form is there's much of an example that I know of for your specific problem.

Erick

On Wed, Oct 8, 2014 at 8:54 AM, Edwards, Joshua <Jo...@capitalone.com> wrote:
> Hi -
>
> I am trying to index a collection that has child documents.  I have successfully loaded the data into my index using SolrJ, and I have verified that I can search correctly using the "child of" method in my fq variable.  Now, I would like to use Velocity (Solritas) to display the parent records with some details of the child records underneath.  Is there an easy way to do this?  Is there an example somewhere that I can look at?
>
> Thanks,
> Josh Edwards
> ________________________________________________________
>
> The information contained in this e-mail is confidential and/or proprietary to Capital One and/or its affiliates. The information transmitted herewith is intended only for use by the individual or entity to which it is addressed.  If the reader of this message is not the intended recipient, you are hereby notified that any review, retransmission, dissemination, distribution, copying or other use of, or taking of any action in reliance upon this information is strictly prohibited. If you have received this communication in error, please contact the sender and delete the material from your computer.
________________________________________________________

The information contained in this e-mail is confidential and/or proprietary to Capital One and/or its affiliates. The information transmitted herewith is intended only for use by the individual or entity to which it is addressed.  If the reader of this message is not the intended recipient, you are hereby notified that any review, retransmission, dissemination, distribution, copying or other use of, or taking of any action in reliance upon this information is strictly prohibited. If you have received this communication in error, please contact the sender and delete the material from your computer.

Re: Using Velocity with Child Documents?

Posted by Erick Erickson <er...@gmail.com>.
Velocity is just taking the Solr response and displaying selected bits
in HTML. So assuming the information you want is in the reponse packet
(which you can tell just by doing the query from the browser) it's
"just" a matter of pulling it out of the response and displaying it.

Mostly when I started down this path I poked around the velocity
directory it was just a bit of hunt int to figure things out, with
some help from the Apache Velocity page.

Not much help, but the short form is there's much of an example that I
know of for your specific problem.

Erick

On Wed, Oct 8, 2014 at 8:54 AM, Edwards, Joshua
<Jo...@capitalone.com> wrote:
> Hi -
>
> I am trying to index a collection that has child documents.  I have successfully loaded the data into my index using SolrJ, and I have verified that I can search correctly using the "child of" method in my fq variable.  Now, I would like to use Velocity (Solritas) to display the parent records with some details of the child records underneath.  Is there an easy way to do this?  Is there an example somewhere that I can look at?
>
> Thanks,
> Josh Edwards
> ________________________________________________________
>
> The information contained in this e-mail is confidential and/or proprietary to Capital One and/or its affiliates. The information transmitted herewith is intended only for use by the individual or entity to which it is addressed.  If the reader of this message is not the intended recipient, you are hereby notified that any review, retransmission, dissemination, distribution, copying or other use of, or taking of any action in reliance upon this information is strictly prohibited. If you have received this communication in error, please contact the sender and delete the material from your computer.