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 "Vinay B," <vy...@gmail.com> on 2014/07/18 00:41:33 UTC

How do I get faceting to work with Solr JOINs

Some Background info :
In our application, we have a requirement to update large number of records
often.  I investigated solr child documents but it requires updating both
the child and the parent document . Therefore, I'm investigating adding
frequently updated information in an "auxillary document" with a custom
defined "parent-id" field that can be used to join with the static "parent
document". - basically rolling my own child document functionality.

This approach has satisfied all my requirements, except one. How can I
facet upon a field present in the auxillary document?

First, here's a gist dump of my test core index (4 docs + 4 aux docs)
https://gist.github.com/anonymous/2774b54e667778c71492

Next, here's a simple facet query only on the aux . While this works, it
only returns auxillary documents
https://gist.github.com/anonymous/a58b87576b895e467c68

Finally, I tweak the query using a SOLR join (
https://wiki.apache.org/solr/Join ) to return the main documents (which it
does), but the faceting returns no results. This is what I'm hoping someone
on this list can answer .
Here is the gist of that query
https://gist.github.com/anonymous/f3a287ab726f35b142cf

Any answers, suggestions ?

Thanks

Re: How do I get faceting to work with Solr JOINs

Posted by "Vinay B," <vy...@gmail.com>.
Thank You, Umesh !

That's a neat approach. Reading through your post, we decided to tweak our
indexing strategy a bit, basically an inversion. We moved all our facetable
(and frequently updated) fields to the main doc and the text and other
static content fields to the sub doc (co-related via a parent id field as
described in my original post). This allows us to satisfy the query
criteria I described.


On Thu, Jul 17, 2014 at 11:58 PM, Umesh Prasad <um...@gmail.com> wrote:

> Hi Vinay,
>
> You can customize the FacetsComponent. Basically FacetComponent uses
> SimpleFacets to compute the facet count. It passes matched docset present
> in responsebuilder to  SimpleFacets's constructor.
>
> 1.  Build a mapping between parent space and auxiliary document space in
> (say an int array) and cache it in your own custom cache in
> SolrIndexSearcher.  You will need to rebuild this mapping on every commit
> have to define a CacheRegenerator for that.
>
> 2.  You can map the matched docset (which is in parent space) to auxiliary
> document space.
>      The catch is that facets from non matching auxililary docs also would
> be counted.
>
> 3. You can then pass on this mapped auxiliary document to SimpleFacets for
> faceting.
>
> I have doing something similar for our needs .. Basically, we have a parent
> document with text attributes and changes very less. And we have child
> documents with inventory attributes which changes extremely fast. The
> search results requires child documents but faceting has to be done on text
> attributes which belong to parents. So we do this mapping by customizing
> the FacetComponent.
>
>
>
>
>
>
> On 18 July 2014 04:11, Vinay B, <vy...@gmail.com> wrote:
>
> > Some Background info :
> > In our application, we have a requirement to update large number of
> records
> > often.  I investigated solr child documents but it requires updating both
> > the child and the parent document . Therefore, I'm investigating adding
> > frequently updated information in an "auxillary document" with a custom
> > defined "parent-id" field that can be used to join with the static
> "parent
> > document". - basically rolling my own child document functionality.
> >
> > This approach has satisfied all my requirements, except one. How can I
> > facet upon a field present in the auxillary document?
> >
> > First, here's a gist dump of my test core index (4 docs + 4 aux docs)
> > https://gist.github.com/anonymous/2774b54e667778c71492
> >
> > Next, here's a simple facet query only on the aux . While this works, it
> > only returns auxillary documents
> > https://gist.github.com/anonymous/a58b87576b895e467c68
> >
> > Finally, I tweak the query using a SOLR join (
> > https://wiki.apache.org/solr/Join ) to return the main documents (which
> it
> > does), but the faceting returns no results. This is what I'm hoping
> someone
> > on this list can answer .
> > Here is the gist of that query
> > https://gist.github.com/anonymous/f3a287ab726f35b142cf
> >
> > Any answers, suggestions ?
> >
> > Thanks
> >
>
>
>
> --
> ---
> Thanks & Regards
> Umesh Prasad
>

Re: How do I get faceting to work with Solr JOINs

Posted by Umesh Prasad <um...@gmail.com>.
Hi Vinay,

You can customize the FacetsComponent. Basically FacetComponent uses
SimpleFacets to compute the facet count. It passes matched docset present
in responsebuilder to  SimpleFacets's constructor.

1.  Build a mapping between parent space and auxiliary document space in
(say an int array) and cache it in your own custom cache in
SolrIndexSearcher.  You will need to rebuild this mapping on every commit
have to define a CacheRegenerator for that.

2.  You can map the matched docset (which is in parent space) to auxiliary
document space.
     The catch is that facets from non matching auxililary docs also would
be counted.

3. You can then pass on this mapped auxiliary document to SimpleFacets for
faceting.

I have doing something similar for our needs .. Basically, we have a parent
document with text attributes and changes very less. And we have child
documents with inventory attributes which changes extremely fast. The
search results requires child documents but faceting has to be done on text
attributes which belong to parents. So we do this mapping by customizing
the FacetComponent.






On 18 July 2014 04:11, Vinay B, <vy...@gmail.com> wrote:

> Some Background info :
> In our application, we have a requirement to update large number of records
> often.  I investigated solr child documents but it requires updating both
> the child and the parent document . Therefore, I'm investigating adding
> frequently updated information in an "auxillary document" with a custom
> defined "parent-id" field that can be used to join with the static "parent
> document". - basically rolling my own child document functionality.
>
> This approach has satisfied all my requirements, except one. How can I
> facet upon a field present in the auxillary document?
>
> First, here's a gist dump of my test core index (4 docs + 4 aux docs)
> https://gist.github.com/anonymous/2774b54e667778c71492
>
> Next, here's a simple facet query only on the aux . While this works, it
> only returns auxillary documents
> https://gist.github.com/anonymous/a58b87576b895e467c68
>
> Finally, I tweak the query using a SOLR join (
> https://wiki.apache.org/solr/Join ) to return the main documents (which it
> does), but the faceting returns no results. This is what I'm hoping someone
> on this list can answer .
> Here is the gist of that query
> https://gist.github.com/anonymous/f3a287ab726f35b142cf
>
> Any answers, suggestions ?
>
> Thanks
>



-- 
---
Thanks & Regards
Umesh Prasad