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 Matthew Runo <mr...@zappos.com> on 2008/01/10 18:28:48 UTC

Dynamic fields & Facets

Hello folks!

I have a small dilemma, and was wondering if anyone would lend some  
guidance. I have a field, called "attributeFacet", and it has lots of  
things like...

Upper Materials/Finishes - Suede
Upper Materials/Finishes - Canvas
Upper Materials/Finishes - Synthetic
Upper Materials/Finishes - Synthetic Leather
Upper Materials/Finishes - Synthetic Nubuck
Lining - Leather
Lining - Canvas
Lining - Mesh
...etc...etc... (there is a totally arbitrary number of these, and  
they're added to all the time).

 From my index, these are currently stored as "Lining::Leather" or  
"Upper Materials/Finishes::Canvas" under an "attribute" field.

I found that this works quite well, but it's something I must change.  
Namely, I cannot facet on "Lining" to get a list of the various  
linings available in a result set, and that is something that I need  
to be able to do.

I've thought that I could use a dynamic field for this, something like  
attribute_<something>. I could strip off the attribute_ part in the  
display easy enough, but I'm not sure how I can facet on all these  
fields. There could be 100s of them in the long term timeframe. I'm  
not sure that addFacetField("attribute_*") would work... but I really  
have no way of knowing exactly what the fields are in advance without  
doing an ugly database call and a loop to add in the facets.

Worst case: I do a "select name from attribute;" and loop through to  
add alllll these facet fields to my query.
Best case: I can do some sort of "addFacetField("attribute_*") magic.

Thanks!

Matthew Runo
Software Developer
Zappos.com
702.943.7833


Re: Dynamic fields & Facets

Posted by Matthew Runo <mr...@zappos.com>.
It would be nice to have the functionality in solr's core...  
Unfortunately I am not qualified to hack on that code =\

Thanks!

Matthew Runo
Software Developer
Zappos.com
702.943.7833

On Jan 10, 2008, at 12:23 PM, Erik Hatcher wrote:

> Solr Flare solves this by first doing a cool hand Luke request  
> handler query to get all the field names, and then in search  
> requests it facets on facet_* but by adding each of those to the  
> HTTP request params.
>
> A Solr-side capability to do it is well warranted in my opinion, I  
> just haven't gotten around to implementing it myself and scratching  
> that itch.  I'm inexperienced with the new query component stuff,  
> but I bet a query component could be easily written to make this  
> dynamic based on the fields in the index.  I do, however, think core  
> support for wildcarded field names everywhere (sensible) that a  
> field name is specified is the way to go.  For example, fl=*_s,*_i.   
> I would rather see a core patch that implemented it in a way that  
> made it pervasive than just for faceting.
>
> 	Erik
>
>
> On Jan 10, 2008, at 12:52 PM, Matthew Runo wrote:
>
>> I see a patch with that ticket from you - that seems to support the  
>> use case of *, but not things otherwise containing a *, such as  
>> attribute_*.
>>
>> I suppose it's not a big deal to look up the attributes from our DB  
>> and go from there, I was just looking for a way to do it all in  
>> Solr if possible.
>>
>> Thanks!
>>
>> Matthew Runo
>> Software Developer
>> Zappos.com
>> 702.943.7833
>>
>> On Jan 10, 2008, at 9:31 AM, Ryan McKinley wrote:
>>
>>>> Best case: I can do some sort of "addFacetField("attribute_*")  
>>>> magic.
>>>
>>> https://issues.apache.org/jira/browse/SOLR-247
>>>
>>> but i don't think there is any progress on it....
>>>
>>>
>>> ryan
>>>
>


Re: Dynamic fields & Facets

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
Solr Flare solves this by first doing a cool hand Luke request  
handler query to get all the field names, and then in search requests  
it facets on facet_* but by adding each of those to the HTTP request  
params.

A Solr-side capability to do it is well warranted in my opinion, I  
just haven't gotten around to implementing it myself and scratching  
that itch.  I'm inexperienced with the new query component stuff, but  
I bet a query component could be easily written to make this dynamic  
based on the fields in the index.  I do, however, think core support  
for wildcarded field names everywhere (sensible) that a field name is  
specified is the way to go.  For example, fl=*_s,*_i.  I would rather  
see a core patch that implemented it in a way that made it pervasive  
than just for faceting.

	Erik


On Jan 10, 2008, at 12:52 PM, Matthew Runo wrote:

> I see a patch with that ticket from you - that seems to support the  
> use case of *, but not things otherwise containing a *, such as  
> attribute_*.
>
> I suppose it's not a big deal to look up the attributes from our DB  
> and go from there, I was just looking for a way to do it all in  
> Solr if possible.
>
> Thanks!
>
> Matthew Runo
> Software Developer
> Zappos.com
> 702.943.7833
>
> On Jan 10, 2008, at 9:31 AM, Ryan McKinley wrote:
>
>>> Best case: I can do some sort of "addFacetField("attribute_*")  
>>> magic.
>>
>> https://issues.apache.org/jira/browse/SOLR-247
>>
>> but i don't think there is any progress on it....
>>
>>
>> ryan
>>


Re: Dynamic fields & Facets

Posted by Matthew Runo <mr...@zappos.com>.
I see a patch with that ticket from you - that seems to support the  
use case of *, but not things otherwise containing a *, such as  
attribute_*.

I suppose it's not a big deal to look up the attributes from our DB  
and go from there, I was just looking for a way to do it all in Solr  
if possible.

Thanks!

Matthew Runo
Software Developer
Zappos.com
702.943.7833

On Jan 10, 2008, at 9:31 AM, Ryan McKinley wrote:

>> Best case: I can do some sort of "addFacetField("attribute_*") magic.
>
> https://issues.apache.org/jira/browse/SOLR-247
>
> but i don't think there is any progress on it....
>
>
> ryan
>


Re: Dynamic fields & Facets

Posted by Ryan McKinley <ry...@gmail.com>.
> 
> Best case: I can do some sort of "addFacetField("attribute_*") magic.
> 

https://issues.apache.org/jira/browse/SOLR-247

but i don't think there is any progress on it....


ryan