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 Brendan Grainger <br...@gmail.com> on 2013/05/11 00:50:11 UTC
Limiting number of facet results for path based facets
Hi,
I'm using the PathHierarchyTokenizer like this:
<fieldType name="descendent_path" class="solr.TextField">
<analyzer type="index">
<tokenizer class="solr.PathHierarchyTokenizerFactory" delimiter="/" />
</analyzer>
<analyzer type="query">
<tokenizer class="solr.KeywordTokenizerFactory" />
</analyzer>
</fieldType>
to create path based facets.
A query like:
http://localhost:8982/solr/articles/select?facet=true&start=0&q=*:*&facet.field=my_path_based_facet&wt=ruby&indent=on
gives facets that look like:
'my_path_based_facet'=>[
'root',4,
'root/books',4,
'root/books/scifi',4,
'root/books/scifi/fantasy',3,
'root/books/scifi/fantasy/general',3,
'root/books/scifi/horror',1,
'root/books/scifi/horror/gore',1,
'root/books/scifi/superhero',1,
'root/books/scifi/superhero/superman',1,
'root/books/scifi/superhero/superman/general',1]}
What I'm wondering if if there is an easy way for me to say I only want up
to level 2 say. So if root was level 0, the returned facets would be:
'root',4,
'root/books',4,
'root/books/scifi',4,
Also given my the description of what I want to achieve is using
PathHierachyTokenizer the correct approach?
Thanks
Brendan
Re: Limiting number of facet results for path based facets
Posted by Brendan Grainger <br...@gmail.com>.
Actually it occurred to me that doing something like this might work:
if I have a category of root/books/scifi for a document I'd create the
following values for the facet:
0/root
1/root
1/root/books
2/root
2/root/books
2/root/books/scifi
Then to get level 1 I'd do:
http://localhost:8982/solr/articles/select?facet=true&start=0&q=*:*&facet.field=my_path_based_facet&wt=ruby&indent=on
&facet.prefix=1/root
Is that what people do?
Thanks
Brendan
On Fri, May 10, 2013 at 6:50 PM, Brendan Grainger <
brendan.grainger@gmail.com> wrote:
> Hi,
>
> I'm using the PathHierarchyTokenizer like this:
>
> <fieldType name="descendent_path" class="solr.TextField">
> <analyzer type="index">
> <tokenizer class="solr.PathHierarchyTokenizerFactory" delimiter="/"
> />
> </analyzer>
> <analyzer type="query">
> <tokenizer class="solr.KeywordTokenizerFactory" />
> </analyzer>
> </fieldType>
>
> to create path based facets.
>
> A query like:
>
>
> http://localhost:8982/solr/articles/select?facet=true&start=0&q=*:*&facet.field=my_path_based_facet&wt=ruby&indent=on
>
> gives facets that look like:
>
> 'my_path_based_facet'=>[
> 'root',4,
> 'root/books',4,
> 'root/books/scifi',4,
> 'root/books/scifi/fantasy',3,
> 'root/books/scifi/fantasy/general',3,
> 'root/books/scifi/horror',1,
> 'root/books/scifi/horror/gore',1,
> 'root/books/scifi/superhero',1,
> 'root/books/scifi/superhero/superman',1,
> 'root/books/scifi/superhero/superman/general',1]}
>
> What I'm wondering if if there is an easy way for me to say I only want up
> to level 2 say. So if root was level 0, the returned facets would be:
>
> 'root',4,
> 'root/books',4,
> 'root/books/scifi',4,
>
>
> Also given my the description of what I want to achieve is using PathHierachyTokenizer the correct approach?
>
> Thanks
> Brendan
>
>
--
Brendan Grainger
www.kuripai.com