[ 
https://issues.apache.org/jira/browse/SOLR-5743?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14298423#comment-14298423
 ] 

Dr Oleg Savrasov commented on SOLR-5743:
----------------------------------------

In order to utilize proposed component, you need to configure it in 
solrconfig.xml and introduce some search handler which uses it, for example

  <searchComponent name="blockJoinFacet" 
class="org.apache.solr.handler.component.BlockJoinFacetComponent">

  </searchComponent>

  <requestHandler name="/blockJoinFacetRH" 
class="org.apache.solr.handler.component.SearchHandler">
    <arr name="last-components">
      <str>blockJoinFacet</str>
    </arr>
  </requestHandler>

Please notice that only string docValues fields could be used for faceting, int 
type can be covered later, so you need to update appropriate fields 
configuration in schema.xml file, for example

 <field name="COLOR_s" type="string" indexed="true" stored="true" 
docValues="true"/>
 <field name="SIZE_s" type="string" indexed="true" stored="true" 
docValues="true"/>


Then after indexing some set of hierarchical documents like

 <doc>
    <field name="id">10</field>
    <field name="type_s">parent</field>
    <field name="BRAND_s">Nike</field>
    <doc>
      <field name="id">11</field>
      <field name="type_s">child</field>
      <field name="COLOR_s">Red</field>
      <field name="SIZE_s">XL</field>
    </doc>
    <doc>
      <field name="id">12</field>
      <field name="type_s">child</field>
      <field name="COLOR_s">Blue</field>
      <field name="SIZE_s">XL</field>
    </doc>
 </doc>

you need to pass required ToParentBlockJoinQuery to the configured request 
handler, for example

 
http://localhost:8983/solr/collection1/blockJoinFacetRH?q={!parent+which%3D%22type_s%3Aparent%22}type_s%3Achild&wt=json&indent=true&facet=true&child.facet.field=COLOR_s&child.facet.field=SIZE_s

and it yields you the desired result

 {
  "responseHeader":{
    "status":0,
    "QTime":1},
  "response":{"numFound":1,"start":0,"docs":[
      {
        "id":"10",
        "type_s":"parent",
        "BRAND_s":"Nike",
        "_version_":1491642108914696192}]
  },
  "facet_counts":{
    "facet_queries":{},
    "facet_fields":{},
    "facet_dates":{},
    "facet_ranges":{},
    "facet_intervals":{},
    "facet_fields":[
      "COLOR_s",[
        "Blue",1,
        "Red",1],
      "SIZE_s",[
        "XL",1]]}}

Please take the latest patch, it contains fix related to just found caching 
issue.

> Faceting with BlockJoin support
> -------------------------------
>
>                 Key: SOLR-5743
>                 URL: https://issues.apache.org/jira/browse/SOLR-5743
>             Project: Solr
>          Issue Type: New Feature
>            Reporter: abipc
>              Labels: features
>         Attachments: SOLR-5743.patch, SOLR-5743.patch, SOLR-5743.patch
>
>
> For a sample inventory(note - nested documents) like this -   
>  <doc>
> <field name="id">10</field>
> <field name="type_s">parent</field>
> <field name="BRAND_s">Nike</field>
> <doc>
> <field name="id">11</field>
> <field name="COLOR_s">Red</field>
> <field name="SIZE_s">XL</field>
> </doc>
> <doc>
> <field name="id">12</field>
> <field name="COLOR_s">Blue</field>
> <field name="SIZE_s">XL</field>
> </doc>
> </doc>
> Faceting results must contain - 
> Red(1)
> XL(1) 
> Blue(1) 
> for a "q=*" query. 
> PS : The inventory example has been taken from this blog - 
> http://blog.griddynamics.com/2013/09/solr-block-join-support.html



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to