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 sam ” <sk...@gmail.com> on 2012/04/18 16:56:57 UTC
hierarchical faceting?
I have hierarchical colors:
<field name="colors" type="text_path" indexed="true"
stored="true" multiValued="true"/>
text_path is TextField with PathHierarchyTokenizerFactory as tokenizer.
Given these two documents,
Doc1: red
Doc2: red/pink
I want the result to be the following:
?fq=red
==> Doc1, Doc2
?fq=red/pink
==> Doc2
But, with PathHierarchyTokenizer, Doc1 is included for the query:
?fq=red/pink
==> Doc1, Doc2
How can I query for hierarchical facets?
http://wiki.apache.org/solr/HierarchicalFaceting describes facet.prefix..
But it looks too cumbersome to me.
Is there a simpler way to implement hierarchical facets?
Re: hierarchical faceting?
Posted by sam ” <sk...@gmail.com>.
yup.
<fieldType name="cq_tag" class="solr.TextField"
positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.PathHierarchyTokenizerFactory"
delimiter="$"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.KeywordTokenizerFactory"/>
</analyzer>
</fieldType>
<field name="colors" type="cq_tag" indexed="true"
stored="true" multiValued="true"/><!-- red$pink, blue ... -->
<field name="colors_facet" type="string" indexed="true"
stored="false" multiValued="true"/><!-- red$pink, blue ... -->
<copyField source="colors" dest="colors_facet"/>
and ?facet.field=colors_facet
On Mon, Apr 30, 2012 at 9:35 PM, Chris Hostetter
<ho...@fucit.org>wrote:
>
> : Is there a tokenizer that tokenizes the string as one token?
>
> Using KeywordTokenizer at query time should do whta you want.
>
>
> -Hoss
>
Re: hierarchical faceting?
Posted by Chris Hostetter <ho...@fucit.org>.
: Is there a tokenizer that tokenizes the string as one token?
Using KeywordTokenizer at query time should do whta you want.
-Hoss
Re: hierarchical faceting?
Posted by Darren Govoni <da...@ontrenet.com>.
I don't use any of that stuff in my app, so not sure how it works.
I just manage my taxonomy outside of solr at index time and don't need
any special fields or tokenizers. I use a string field type and insert
the proper field at index time and query it normally. Nothing special
required.
On Wed, 2012-04-18 at 13:00 -0400, sam ” wrote:
> It looks like TextField is the problem.
>
> This fixed:
> <fieldType name="text_path" class="solr.TextField"
> positionIncrementGap="100">
> <analyzer type="index">
> <tokenizer class="solr.PathHierarchyTokenizerFactory"
> delimiter="/"/>
> </analyzer>
> <analyzer type="query">
> <tokenizer class="solr.WhitespaceTokenizerFactory"/>
> </analyzer>
> </fieldType>
>
> I am assuming the text_path fields won't include whitespace characters.
>
> ?q=colors:red/pink
> ==> Doc2 (Doc1, which has colors = red isn't included!)
>
>
> Is there a tokenizer that tokenizes the string as one token?
> I tried to extend Tokenizer myself but it fails:
> public class AsIsTokenizer extends Tokenizer {
> @Override
> public boolean incrementToken() throws IOException {
> return true;//or false;
> }
> }
>
>
> On Wed, Apr 18, 2012 at 11:33 AM, sam ” <sk...@gmail.com> wrote:
>
> > Yah, that's exactly what PathHierarchyTokenizer does.
> > <fieldType name="text_path" class="solr.TextField"
> > positionIncrementGap="100">
> > <analyzer type="index">
> > <tokenizer class="solr.PathHierarchyTokenizerFactory"/>
> > </analyzer>
> > </fieldType>
> >
> > I think I have a query time tokenizer that tokenizes at /
> >
> > ?q=colors:red
> > ==> Doc1, Doc2
> >
> > ?q=colors:redfoobar
> > ==>
> >
> > ?q=colors:red/foobarasdfoaijao
> > ==> Doc1, Doc2
> >
> >
> >
> >
> > On Wed, Apr 18, 2012 at 11:10 AM, Darren Govoni <da...@ontrenet.com>wrote:
> >
> >> Put the parent term in all the child documents at index time
> >> and the re-issue the facet query when you expand the parent using the
> >> parent's term. works perfect.
> >>
> >> On Wed, 2012-04-18 at 10:56 -0400, sam ” wrote:
> >> > I have hierarchical colors:
> >> > <field name="colors" type="text_path" indexed="true"
> >> > stored="true" multiValued="true"/>
> >> > text_path is TextField with PathHierarchyTokenizerFactory as tokenizer.
> >> >
> >> > Given these two documents,
> >> > Doc1: red
> >> > Doc2: red/pink
> >> >
> >> > I want the result to be the following:
> >> > ?fq=red
> >> > ==> Doc1, Doc2
> >> >
> >> > ?fq=red/pink
> >> > ==> Doc2
> >> >
> >> > But, with PathHierarchyTokenizer, Doc1 is included for the query:
> >> > ?fq=red/pink
> >> > ==> Doc1, Doc2
> >> >
> >> > How can I query for hierarchical facets?
> >> > http://wiki.apache.org/solr/HierarchicalFaceting describes
> >> facet.prefix..
> >> > But it looks too cumbersome to me.
> >> >
> >> > Is there a simpler way to implement hierarchical facets?
> >>
> >>
> >>
> >
Re: hierarchical faceting?
Posted by sam ” <sk...@gmail.com>.
It looks like TextField is the problem.
This fixed:
<fieldType name="text_path" class="solr.TextField"
positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.PathHierarchyTokenizerFactory"
delimiter="/"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
</analyzer>
</fieldType>
I am assuming the text_path fields won't include whitespace characters.
?q=colors:red/pink
==> Doc2 (Doc1, which has colors = red isn't included!)
Is there a tokenizer that tokenizes the string as one token?
I tried to extend Tokenizer myself but it fails:
public class AsIsTokenizer extends Tokenizer {
@Override
public boolean incrementToken() throws IOException {
return true;//or false;
}
}
On Wed, Apr 18, 2012 at 11:33 AM, sam ” <sk...@gmail.com> wrote:
> Yah, that's exactly what PathHierarchyTokenizer does.
> <fieldType name="text_path" class="solr.TextField"
> positionIncrementGap="100">
> <analyzer type="index">
> <tokenizer class="solr.PathHierarchyTokenizerFactory"/>
> </analyzer>
> </fieldType>
>
> I think I have a query time tokenizer that tokenizes at /
>
> ?q=colors:red
> ==> Doc1, Doc2
>
> ?q=colors:redfoobar
> ==>
>
> ?q=colors:red/foobarasdfoaijao
> ==> Doc1, Doc2
>
>
>
>
> On Wed, Apr 18, 2012 at 11:10 AM, Darren Govoni <da...@ontrenet.com>wrote:
>
>> Put the parent term in all the child documents at index time
>> and the re-issue the facet query when you expand the parent using the
>> parent's term. works perfect.
>>
>> On Wed, 2012-04-18 at 10:56 -0400, sam ” wrote:
>> > I have hierarchical colors:
>> > <field name="colors" type="text_path" indexed="true"
>> > stored="true" multiValued="true"/>
>> > text_path is TextField with PathHierarchyTokenizerFactory as tokenizer.
>> >
>> > Given these two documents,
>> > Doc1: red
>> > Doc2: red/pink
>> >
>> > I want the result to be the following:
>> > ?fq=red
>> > ==> Doc1, Doc2
>> >
>> > ?fq=red/pink
>> > ==> Doc2
>> >
>> > But, with PathHierarchyTokenizer, Doc1 is included for the query:
>> > ?fq=red/pink
>> > ==> Doc1, Doc2
>> >
>> > How can I query for hierarchical facets?
>> > http://wiki.apache.org/solr/HierarchicalFaceting describes
>> facet.prefix..
>> > But it looks too cumbersome to me.
>> >
>> > Is there a simpler way to implement hierarchical facets?
>>
>>
>>
>
Re: hierarchical faceting?
Posted by sam ” <sk...@gmail.com>.
Yah, that's exactly what PathHierarchyTokenizer does.
<fieldType name="text_path" class="solr.TextField"
positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.PathHierarchyTokenizerFactory"/>
</analyzer>
</fieldType>
I think I have a query time tokenizer that tokenizes at /
?q=colors:red
==> Doc1, Doc2
?q=colors:redfoobar
==>
?q=colors:red/foobarasdfoaijao
==> Doc1, Doc2
On Wed, Apr 18, 2012 at 11:10 AM, Darren Govoni <da...@ontrenet.com> wrote:
> Put the parent term in all the child documents at index time
> and the re-issue the facet query when you expand the parent using the
> parent's term. works perfect.
>
> On Wed, 2012-04-18 at 10:56 -0400, sam ” wrote:
> > I have hierarchical colors:
> > <field name="colors" type="text_path" indexed="true"
> > stored="true" multiValued="true"/>
> > text_path is TextField with PathHierarchyTokenizerFactory as tokenizer.
> >
> > Given these two documents,
> > Doc1: red
> > Doc2: red/pink
> >
> > I want the result to be the following:
> > ?fq=red
> > ==> Doc1, Doc2
> >
> > ?fq=red/pink
> > ==> Doc2
> >
> > But, with PathHierarchyTokenizer, Doc1 is included for the query:
> > ?fq=red/pink
> > ==> Doc1, Doc2
> >
> > How can I query for hierarchical facets?
> > http://wiki.apache.org/solr/HierarchicalFaceting describes
> facet.prefix..
> > But it looks too cumbersome to me.
> >
> > Is there a simpler way to implement hierarchical facets?
>
>
>
Re: hierarchical faceting?
Posted by Darren Govoni <da...@ontrenet.com>.
Put the parent term in all the child documents at index time
and the re-issue the facet query when you expand the parent using the
parent's term. works perfect.
On Wed, 2012-04-18 at 10:56 -0400, sam ” wrote:
> I have hierarchical colors:
> <field name="colors" type="text_path" indexed="true"
> stored="true" multiValued="true"/>
> text_path is TextField with PathHierarchyTokenizerFactory as tokenizer.
>
> Given these two documents,
> Doc1: red
> Doc2: red/pink
>
> I want the result to be the following:
> ?fq=red
> ==> Doc1, Doc2
>
> ?fq=red/pink
> ==> Doc2
>
> But, with PathHierarchyTokenizer, Doc1 is included for the query:
> ?fq=red/pink
> ==> Doc1, Doc2
>
> How can I query for hierarchical facets?
> http://wiki.apache.org/solr/HierarchicalFaceting describes facet.prefix..
> But it looks too cumbersome to me.
>
> Is there a simpler way to implement hierarchical facets?