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 Nea <ne...@me.com> on 2013/11/09 13:09:16 UTC
HierarchicalFaceting for Ecommerce Categories
Hi Everybody,
I’m using Solr 4.5.1 and I need to achieve a HierarchicalFaceting for leveled categories. Someone can explain me how schema.xml and query should be?
My category path is;
Cameras > Camcorders [ 5 items]
Cameras > Digital Cameras
Cameras > Digital Cameras > Digital SLR [15 items]
Cameras > Digital Cameras > Mirrorless Cameras [ 4 items]
And i want to facet as;
first query:
cameras (24)
second level query
camorders (5)
digital cameras (19)
third level facet query for digital cameras
digital slr (15)
mirrorless (4)
ty.
Re: HierarchicalFaceting for Ecommerce Categories
Posted by Upayavira <uv...@odoko.co.uk>.
On Sat, Nov 9, 2013, at 06:18 PM, Nea wrote:
> Thanks for ur reply. I got it.
>
> My old implementation on solr 3.1 was multivalued string field with
> 1_catL1, 2_catL2, and doing it with prefix and tagging.
> I thought at 4.5.1, can be a nice way doing it :(
The PathHierarchyTokenizerFactory can *almost* do it. It probably
wouldn't take much tweaking so you don't need to do it in your own
code...
Upayavira
Re: HierarchicalFaceting for Ecommerce Categories
Posted by Nea <ne...@me.com>.
Thanks for ur reply. I got it.
My old implementation on solr 3.1 was multivalued string field with 1_catL1, 2_catL2, and doing it with prefix and tagging.
I thought at 4.5.1, can be a nice way doing it :(
On Nov 9, 2013, at 20:10, Upayavira <uv...@odoko.co.uk> wrote:
> You want to use descendent_path. If you have a delimiter of /, then:
>
> books/it/programming/java
>
> would become:
>
> books
> books/IT
> books/IT/programming
> books/IT/programming/java
>
> Meaning you can facet on this field. If you wish to get a specific level
> only, then you need to either do your own splitting, or extend the
> PathHierarchyTokenizerFactory to be able to do it like this:
>
> 1:books
> 2:books/IT
> 3:books/IT/programming
> 4:books/IT/programming/java
>
> Then, you can use facet.prefix to search for a specific level in the
> hierarchy. Fixing the PathHierarchyTokenizer would be great for all of
> us.
>
> Upayavira
>
> On Sat, Nov 9, 2013, at 03:19 PM, Nea wrote:
>> HierarchicalFaceting documentation does not clearly explain how to index
>> and query field types "descendent_path and ancestor_path” included in
>> schema.xml.
>>
>> Any help would be greatly appreciated.
>>
>>
>> <!--
>> Example of using PathHierarchyTokenizerFactory at index time, so
>> queries for paths match documents at that path, or in descendent
>> paths
>> —>
>>
>> <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>
>>
>> <!--
>> Example of using PathHierarchyTokenizerFactory at query time, so
>> queries for paths match documents at that path, or in ancestor
>> paths
>> —>
>>
>> <fieldType name="ancestor_path" class="solr.TextField">
>> <analyzer type="index">
>> <tokenizer class="solr.KeywordTokenizerFactory" />
>> </analyzer>
>> <analyzer type="query">
>> <tokenizer class="solr.PathHierarchyTokenizerFactory" delimiter="/" />
>> </analyzer>
>> </fieldType>
>>
>>
>> On Nov 9, 2013, at 15:22, Upayavira <uv...@odoko.co.uk> wrote:
>>
>>> http://wiki.apache.org/solr/HierarchicalFaceting
>>>
>>> Upayavira
>>>
>>> On Sat, Nov 9, 2013, at 12:09 PM, Nea wrote:
>>>> Hi Everybody,
>>>>
>>>> I’m using Solr 4.5.1 and I need to achieve a HierarchicalFaceting for
>>>> leveled categories. Someone can explain me how schema.xml and query
>>>> should be?
>>>>
>>>>
>>>> My category path is;
>>>>
>>>> Cameras > Camcorders [
>>>> 5 items]
>>>> Cameras > Digital Cameras
>>>> Cameras > Digital Cameras > Digital SLR [15 items]
>>>> Cameras > Digital Cameras > Mirrorless Cameras [ 4 items]
>>>>
>>>>
>>>> And i want to facet as;
>>>>
>>>> first query:
>>>> cameras (24)
>>>>
>>>> second level query
>>>> camorders (5)
>>>> digital cameras (19)
>>>>
>>>> third level facet query for digital cameras
>>>> digital slr (15)
>>>> mirrorless (4)
>>>>
>>>>
>>>> ty.
>>>>
>>>>
>>
Re: HierarchicalFaceting for Ecommerce Categories
Posted by Upayavira <uv...@odoko.co.uk>.
You want to use descendent_path. If you have a delimiter of /, then:
books/it/programming/java
would become:
books
books/IT
books/IT/programming
books/IT/programming/java
Meaning you can facet on this field. If you wish to get a specific level
only, then you need to either do your own splitting, or extend the
PathHierarchyTokenizerFactory to be able to do it like this:
1:books
2:books/IT
3:books/IT/programming
4:books/IT/programming/java
Then, you can use facet.prefix to search for a specific level in the
hierarchy. Fixing the PathHierarchyTokenizer would be great for all of
us.
Upayavira
On Sat, Nov 9, 2013, at 03:19 PM, Nea wrote:
> HierarchicalFaceting documentation does not clearly explain how to index
> and query field types "descendent_path and ancestor_path” included in
> schema.xml.
>
> Any help would be greatly appreciated.
>
>
> <!--
> Example of using PathHierarchyTokenizerFactory at index time, so
> queries for paths match documents at that path, or in descendent
> paths
> —>
>
> <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>
>
> <!--
> Example of using PathHierarchyTokenizerFactory at query time, so
> queries for paths match documents at that path, or in ancestor
> paths
> —>
>
> <fieldType name="ancestor_path" class="solr.TextField">
> <analyzer type="index">
> <tokenizer class="solr.KeywordTokenizerFactory" />
> </analyzer>
> <analyzer type="query">
> <tokenizer class="solr.PathHierarchyTokenizerFactory" delimiter="/" />
> </analyzer>
> </fieldType>
>
>
> On Nov 9, 2013, at 15:22, Upayavira <uv...@odoko.co.uk> wrote:
>
> > http://wiki.apache.org/solr/HierarchicalFaceting
> >
> > Upayavira
> >
> > On Sat, Nov 9, 2013, at 12:09 PM, Nea wrote:
> >> Hi Everybody,
> >>
> >> I’m using Solr 4.5.1 and I need to achieve a HierarchicalFaceting for
> >> leveled categories. Someone can explain me how schema.xml and query
> >> should be?
> >>
> >>
> >> My category path is;
> >>
> >> Cameras > Camcorders [
> >> 5 items]
> >> Cameras > Digital Cameras
> >> Cameras > Digital Cameras > Digital SLR [15 items]
> >> Cameras > Digital Cameras > Mirrorless Cameras [ 4 items]
> >>
> >>
> >> And i want to facet as;
> >>
> >> first query:
> >> cameras (24)
> >>
> >> second level query
> >> camorders (5)
> >> digital cameras (19)
> >>
> >> third level facet query for digital cameras
> >> digital slr (15)
> >> mirrorless (4)
> >>
> >>
> >> ty.
> >>
> >>
>
Re: HierarchicalFaceting for Ecommerce Categories
Posted by Nea <ne...@me.com>.
HierarchicalFaceting documentation does not clearly explain how to index and query field types "descendent_path and ancestor_path” included in schema.xml.
Any help would be greatly appreciated.
<!--
Example of using PathHierarchyTokenizerFactory at index time, so
queries for paths match documents at that path, or in descendent paths
—>
<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>
<!--
Example of using PathHierarchyTokenizerFactory at query time, so
queries for paths match documents at that path, or in ancestor paths
—>
<fieldType name="ancestor_path" class="solr.TextField">
<analyzer type="index">
<tokenizer class="solr.KeywordTokenizerFactory" />
</analyzer>
<analyzer type="query">
<tokenizer class="solr.PathHierarchyTokenizerFactory" delimiter="/" />
</analyzer>
</fieldType>
On Nov 9, 2013, at 15:22, Upayavira <uv...@odoko.co.uk> wrote:
> http://wiki.apache.org/solr/HierarchicalFaceting
>
> Upayavira
>
> On Sat, Nov 9, 2013, at 12:09 PM, Nea wrote:
>> Hi Everybody,
>>
>> I’m using Solr 4.5.1 and I need to achieve a HierarchicalFaceting for
>> leveled categories. Someone can explain me how schema.xml and query
>> should be?
>>
>>
>> My category path is;
>>
>> Cameras > Camcorders [
>> 5 items]
>> Cameras > Digital Cameras
>> Cameras > Digital Cameras > Digital SLR [15 items]
>> Cameras > Digital Cameras > Mirrorless Cameras [ 4 items]
>>
>>
>> And i want to facet as;
>>
>> first query:
>> cameras (24)
>>
>> second level query
>> camorders (5)
>> digital cameras (19)
>>
>> third level facet query for digital cameras
>> digital slr (15)
>> mirrorless (4)
>>
>>
>> ty.
>>
>>
Re: HierarchicalFaceting for Ecommerce Categories
Posted by Upayavira <uv...@odoko.co.uk>.
http://wiki.apache.org/solr/HierarchicalFaceting
Upayavira
On Sat, Nov 9, 2013, at 12:09 PM, Nea wrote:
> Hi Everybody,
>
> I’m using Solr 4.5.1 and I need to achieve a HierarchicalFaceting for
> leveled categories. Someone can explain me how schema.xml and query
> should be?
>
>
> My category path is;
>
> Cameras > Camcorders [
> 5 items]
> Cameras > Digital Cameras
> Cameras > Digital Cameras > Digital SLR [15 items]
> Cameras > Digital Cameras > Mirrorless Cameras [ 4 items]
>
>
> And i want to facet as;
>
> first query:
> cameras (24)
>
> second level query
> camorders (5)
> digital cameras (19)
>
> third level facet query for digital cameras
> digital slr (15)
> mirrorless (4)
>
>
> ty.
>
>