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 "adrian.stringer@holidaylettings.co.uk" <ad...@holidaylettings.co.uk> on 2012/03/02 13:21:20 UTC

Retrieving multiple levels with hierarchical faceting in Solr

I've got a hierarchical facet in my Solr collection; root level values are prefixed with 0;, and the next level is prefixed 1_foovalue;.  I can get the root level easily enough, but when foovalue is selected I need to retrieve the next level in the hierarchy while still displaying all of the options in the root level.  I can't work out how to request either two different prefixes for the facet, or the same facet twice using different prefixes.

I've found a couple of discussions online that suggest I ought to be able to set the prefix using local params:

    facet.field={!prefix=0;}foo
    facet.field={!prefix=1_foovalue; key=bar}foo

but the prefix seems to be ignored, as the facet returned contains all values.  Should I just <copyField source="foo" dest="bar" /> so I can query using f.foo.facet.prefix=0;&f.bar.facet.prefix=1_foovalue;, or is there another way I can request the two different levels of my facet hierarchy at once?

I'm using Solr 3.5.

Thanks,
Ade


Re: Retrieving multiple levels with hierarchical faceting in Solr

Posted by Chris Hostetter <ho...@fucit.org>.
: I've found a couple of discussions online that suggest I ought to be 
: able to set the prefix using local params:
: 
:     facet.field={!prefix=0;}foo
:     facet.field={!prefix=1_foovalue; key=bar}foo

citation please?

as far as i know that has ever been implemented, but the idea was floated 
arround as a hypothetical.

There is an open feature request for this type of logic, and it has a 
patch, but that patch doesn't work against any recent version 
(contributions to get it up to snuff would certianly be welcome)...

https://issues.apache.org/jira/browse/SOLR-1351
https://issues.apache.org/jira/browse/SOLR-2251


-Hoss

Re: Retrieving multiple levels with hierarchical faceting in Solr

Posted by Erick Erickson <er...@gmail.com>.
I should have read more carefully. Why not just use facet.query? They are
treated completely independently, so you can specify something like:
facet.query=field:0*
facet.query=field:1_foovalue*
and you can even specify facet.field as well, they all just come back
as separate sections in the facets list of the response.

Best
Erick

On Sun, Mar 4, 2012 at 7:52 AM, adrian.stringer@holidaylettings.co.uk
<ad...@holidaylettings.co.uk> wrote:
> At the moment, I'm just using a multi-valued string field.  I was previously using a text field that was defined as follows:
>
>        <fieldtype name="foo" class="solr.TextField" indexed="true">
>                <analyzer>
>                        <tokenizer class="solr.WhitespaceTokenizerFactory" />
>                        <filter class="solr.PatternReplaceFilterFactory" pattern="\+" replacement=" " />
>                </analyzer>
>        </fieldtype>
>
> I've tried to have a look on the net, but I can't seem to find any documentation on the difference between specifying a facet prefix using f.facetname.facet.prefix and using local params - if anyone could point me in the right direction it'd be much appreciated.  From what I can see, it appears that my Solr instance just ignores the prefix when supplied via local params.  I suspect that, as I don't know much about Solr, I'm probably just searching for the wrong phrases :(
>
> Regards,
> Ade
>
> -----Original Message-----
> From: Erick Erickson [mailto:erickerickson@gmail.com]
> Sent: 03 March 2012 00:36
> To: solr-user@lucene.apache.org
> Subject: Re: Retrieving multiple levels with hierarchical faceting in Solr
>
> A lot depends on the analysis chain your field is actually using, that is the tokens that are in the index. Can you supply the schema.xml file for the field in question?
>
> Best
> Erick
>
> On Fri, Mar 2, 2012 at 7:21 AM, adrian.stringer@holidaylettings.co.uk
> <ad...@holidaylettings.co.uk> wrote:
>> I've got a hierarchical facet in my Solr collection; root level values are prefixed with 0;, and the next level is prefixed 1_foovalue;.  I can get the root level easily enough, but when foovalue is selected I need to retrieve the next level in the hierarchy while still displaying all of the options in the root level.  I can't work out how to request either two different prefixes for the facet, or the same facet twice using different prefixes.
>>
>> I've found a couple of discussions online that suggest I ought to be able to set the prefix using local params:
>>
>>    facet.field={!prefix=0;}foo
>>    facet.field={!prefix=1_foovalue; key=bar}foo
>>
>> but the prefix seems to be ignored, as the facet returned contains all values.  Should I just <copyField source="foo" dest="bar" /> so I can query using f.foo.facet.prefix=0;&f.bar.facet.prefix=1_foovalue;, or is there another way I can request the two different levels of my facet hierarchy at once?
>>
>> I'm using Solr 3.5.
>>
>> Thanks,
>> Ade
>>

RE: Retrieving multiple levels with hierarchical faceting in Solr

Posted by "adrian.stringer@holidaylettings.co.uk" <ad...@holidaylettings.co.uk>.
At the moment, I'm just using a multi-valued string field.  I was previously using a text field that was defined as follows:

	<fieldtype name="foo" class="solr.TextField" indexed="true">
		<analyzer>
			<tokenizer class="solr.WhitespaceTokenizerFactory" />
			<filter class="solr.PatternReplaceFilterFactory" pattern="\+" replacement=" " />
		</analyzer>
	</fieldtype>

I've tried to have a look on the net, but I can't seem to find any documentation on the difference between specifying a facet prefix using f.facetname.facet.prefix and using local params - if anyone could point me in the right direction it'd be much appreciated.  From what I can see, it appears that my Solr instance just ignores the prefix when supplied via local params.  I suspect that, as I don't know much about Solr, I'm probably just searching for the wrong phrases :(

Regards,
Ade

-----Original Message-----
From: Erick Erickson [mailto:erickerickson@gmail.com] 
Sent: 03 March 2012 00:36
To: solr-user@lucene.apache.org
Subject: Re: Retrieving multiple levels with hierarchical faceting in Solr

A lot depends on the analysis chain your field is actually using, that is the tokens that are in the index. Can you supply the schema.xml file for the field in question?

Best
Erick

On Fri, Mar 2, 2012 at 7:21 AM, adrian.stringer@holidaylettings.co.uk
<ad...@holidaylettings.co.uk> wrote:
> I've got a hierarchical facet in my Solr collection; root level values are prefixed with 0;, and the next level is prefixed 1_foovalue;.  I can get the root level easily enough, but when foovalue is selected I need to retrieve the next level in the hierarchy while still displaying all of the options in the root level.  I can't work out how to request either two different prefixes for the facet, or the same facet twice using different prefixes.
>
> I've found a couple of discussions online that suggest I ought to be able to set the prefix using local params:
>
>    facet.field={!prefix=0;}foo
>    facet.field={!prefix=1_foovalue; key=bar}foo
>
> but the prefix seems to be ignored, as the facet returned contains all values.  Should I just <copyField source="foo" dest="bar" /> so I can query using f.foo.facet.prefix=0;&f.bar.facet.prefix=1_foovalue;, or is there another way I can request the two different levels of my facet hierarchy at once?
>
> I'm using Solr 3.5.
>
> Thanks,
> Ade
>

Re: Retrieving multiple levels with hierarchical faceting in Solr

Posted by Erick Erickson <er...@gmail.com>.
A lot depends on the analysis chain your field is actually using, that is
the tokens that are in the index. Can you supply the schema.xml
file for the field in question?

Best
Erick

On Fri, Mar 2, 2012 at 7:21 AM, adrian.stringer@holidaylettings.co.uk
<ad...@holidaylettings.co.uk> wrote:
> I've got a hierarchical facet in my Solr collection; root level values are prefixed with 0;, and the next level is prefixed 1_foovalue;.  I can get the root level easily enough, but when foovalue is selected I need to retrieve the next level in the hierarchy while still displaying all of the options in the root level.  I can't work out how to request either two different prefixes for the facet, or the same facet twice using different prefixes.
>
> I've found a couple of discussions online that suggest I ought to be able to set the prefix using local params:
>
>    facet.field={!prefix=0;}foo
>    facet.field={!prefix=1_foovalue; key=bar}foo
>
> but the prefix seems to be ignored, as the facet returned contains all values.  Should I just <copyField source="foo" dest="bar" /> so I can query using f.foo.facet.prefix=0;&f.bar.facet.prefix=1_foovalue;, or is there another way I can request the two different levels of my facet hierarchy at once?
>
> I'm using Solr 3.5.
>
> Thanks,
> Ade
>