Hi Darren.  You said: 

"Your UI will associate the correct parent id to build the facet query"

This is the part I'm having trouble figuring out how to accomplish and some 
guidance would help. How would I get the value of the parent to build the facet 
query in the UI, if the value is in another document field?  I was imagining 
that I would add the additional filter of "parent:<parent path>" to the "fq" 
URL parameter.  But I don't have a way to do it yet.

Perhaps seeing some data would help.  Here is a record in old (flattened) and 
new (parent-enabled) versions, both in JSON format:

OLD:
    {
        "ID" : "3816",
        "Gene Symbol" : "KLK1",
        "Alternate Names" : "hCG_22931;Klk6;hK1;KLKR",
        "Description" : "Kallikrein 1, a peptidase that cleaves kininogen, 
functions in glucose homeostasis, heart contraction, semen liquefaction, and 
vasoconstriction, aberrantly expressed in pancreatitis and endometrial cancer; 
gene polymorphism correlates with kidney failure (BKL)",
        "GAD_Positive_Disease_Associations" : ["Mental Disorders(MESH:D001523) 
>> Dementia, Vascular(MESH:D015140)", "Cardiovascular Diseases(MESH:D002318) >> 
Coronary Artery Disease(MESH:D003324)"],
        "HuGENet_GeneProspector_Associations" : ["atherosclerosis", "HDL"],
    }



NEW:
    {
        "ID" : "3816",
        "Gene Symbol" : "KLK1",
        "Alternate Names" : "hCG_22931;Klk6;hK1;KLKR",
        "Description" : "Kallikrein 1, a peptidase that cleaves kininogen, 
functions in glucose homeostasis, heart contraction, semen liquefaction, and 
vasoconstriction, aberrantly expressed in pancreatitis and endometrial cancer; 
gene polymorphism correlates with kidney failure (BKL)",
        "GAD_Positive_Disease_Associations" : ["Dementia, 
Vascular(MESH:D015140)", "Coronary Artery Disease(MESH:D003324)"],
        "GAD_Positive_Disease_Associations_parent" : ["Mental 
Disorders(MESH:D001523)", "Cardiovascular Diseases(MESH:D002318)"],
        "HuGENet_GeneProspector_Associations" : ["atherosclerosis", "HDL"],
    }

In the old version, the field "GAD_Positive_Disease_Associations" had 2 levels 
of hierarchy that were flattened.  It had the full path of the hierarchy 
leading to the current term.  In the new version, the field only has the 
current term.  A separate field called 
"GAD_Positive_Disease_Associations_parent" has the full path preceding the 
current term.

So, let's say in the UI, I click on the term "Dementia, Vascular(MESH:D015140)" 
to get its child terms and data.  My filters in the URL querystring would be 
exactly: 

fq=GAD_Positive_Disease_Associations:"Dementia, 
Vascular(MESH:D015140)"&fq=GAD_Positive_Disease_Associations_parent:"Mental 
Disorders(MESH:D001523)"

My question is, how to get the parent value of "Mental Disorders(MESH:D001523)" 
to build that querystring?

Thanks!

Yuhao




________________________________
 From: Darren Govoni <dar...@ontrenet.com>
To: solr-user@lucene.apache.org 
Sent: Tuesday, January 24, 2012 1:23 PM
Subject: Re: Hierarchical faceting in UI
 
Yuhao,
     Ok, let me think about this. A term can have multiple parents. Each of 
those parents would be 'different', yes?
In this case, use a multivalued field for the parent and add all the parent 
names or id's to it. The relations should be unique.

Your UI will associate the correct parent id to build the facet query from and 
return the correct children because the user
is descending down a specific path in the UI and the parent node unique id's 
are returned along the way.

Now, if you are having parent names/id's that themselves can appear in multiple 
locations (vs. just terms 'the leafs'),
then perhaps your hierarchy needs refactoring for redundancy?

Happy to help with more details.

Darren


On 01/24/2012 11:22 AM, Yuhao wrote:
> Darren,
>
> One challenge for me is that a term can appear in multiple places of the 
> hierarchy.  So it's not safe to simply use the term as it appears to get its 
> children; I probably need to include the entire tree path up to this term.  
> For example, if the hierarchy is "Cardiovascular Diseases>  
> Arteriosclerosis>  Coronary Artery Disease", and I'm getting the children of 
> the middle term Arteriosclerosi, I need to filter on something like 
> "parent:Cardiovascular Diseases/Arteriosclerosis".
>
> I'm having trouble figuring out how I can get the complete path per above to 
> add to the URL of each facet term.  I know "velocity/facet_field.vm" is where 
> I build the URL.  I know how to simply add a "parent:<term>" filter to the 
> URL.  But I don't know how to access a document field, like the complete 
> parent path, in "facet_field.vm".  Any help would be great.
>
> Yuhao
>
>
>
>
> ________________________________
>   From: "dar...@ontrenet.com"<dar...@ontrenet.com>
> To: Yuhao<nfsvi...@yahoo.com>
> Cc: solr-user@lucene.apache.org
> Sent: Monday, January 23, 2012 7:16 PM
> Subject: Re: Hierarchical faceting in UI
>
>
> On Mon, 23 Jan 2012 14:33:00 -0800 (PST), Yuhao<nfsvi...@yahoo.com>
> wrote:
>> Programmatically, something like this might work: for each facet field,
>> add another hidden field that identifies its parent.  Then, program
>> additional logic in the UI to show only the facet terms at the currently
>> selected level.  For example, if one filters on "cat:electronics", the
> new
>> UI logic would apply the additional filter "cat_parent:electronics".
> Can
>> this be done?
> Yes. This is how I do it.
>
>> Would it be a lot of work?
> No. Its not a lot of work, simply represent your hierarchy as parent/child
> relations in the document fields and in your UI drill down by issuing new
> faceted searches. Use the current facet (tree level) as the parent:<level>
> in the next query. Its much easier than other suggestions for this.
>
>> Is there a better way?
> Not in my opinion, there isn't. This is the simplest to implement and
> understand.
>
>> By the way, Flamenco (another faceted browser) has built-in support for
>> hierarchies, and it has worked well for my data in this aspect (but less
>> well than Solr in others).  I'm looking for the same kind of
> hierarchical
>> UI feature in Solr.

Reply via email to