lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Hostetter <hossman_luc...@fucit.org>
Subject Re: Using Velocity with Child Documents?
Date Wed, 08 Oct 2014 22:13:01 GMT

: 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/

Mime
View raw message