Facet a multivalued field

1,156 views
Skip to first unread message

chilakilez

unread,
May 5, 2011, 10:48:23 AM5/5/11
to PHP Solr Client
$extraSettings = array("facet" => "true", # Turn faceting on
'facet.mincount' => "1", # Just displays those that
are above 0
'facet.limit' => '-1'), # facet.limit by
default will only load 100 faceted categories, -1 (infinite)
'facet.field' => 'words'); # facet.field
Facet words field

$response = $this->_solr->search($query, $pim_offset, $pim_limit,
$extraSettings);

Does the above work for multivalued fields? i have a multivalued field
called words, and for some reason i'm unable to facet it via solr-php-
client.
Am I missing something in here?
My problem is that is one document contains two or more words, the
faceting doesn't add these up, so if have:
<id>1</id>
<title>Hello</title>
<arr name="words">
<str>builders</str>
<str>builders</str>
<str>buildings</str>
<str>buildings</str>
<str>construction</str>
<str>construction</str>
<str>green</str>
<str>green</str>
</arr>

It just shows up:

<lst name="words">
<int name="builders_NNS">1</int>
<int name="buildings_NNS">1</int>
<int name="construction_NN">1</int>
<int name="green_JJ">1</int>

I'm not sure if this a solr-php-client related question (as faceting
in other fields works fine) or more towards Solr functionality
itlsef...
Would appreciate the help

donovan...@gmail.com

unread,
May 5, 2011, 11:05:50 AM5/5/11
to php-sol...@googlegroups.com
You can facet on multivalued fields, but i don't think its going to return results like you want. The facet counts are the number of documents that both match the query and have a particular field term (no matter how many times). It won't return the number of times a term occurs over all those documents like I think you're expecting in your example. I'm not sure of any search component that currently does that. You might want to ask the solr user lists: http://lucene.apache.org/solr/mailing_lists.html

Hope I understood your question and was helpful,
- Donovan


On May 5, 2011 10:48am, chilakilez <chila...@gmail.com> wrote:
>  $extraSettings = array("facet" => "true", # Turn faceting on
>
>                'facet.mincount' => "1",  # Just displays those that
>
> are above 0
>
>                'facet.limit' => '-1'),           # facet.limit by
>
> default will only load 100 faceted categories, -1 (infinite)
>
>                'facet.field' => 'words');           # facet.field
>
> Facet words field
>
>
>
> $response = $this->_solr->search($query, $pim_offset, $pim_limit,
>
> $extraSettings);
>
>
>
> Does the above work for multivalued fields? i have a multivalued field
>
> called words, and for some reason i'm unable to facet it via solr-php-
>
> client.
>
> Am I missing something in here?
>
> My problem is that is one document contains two or more words, the
>
> faceting doesn't add these up, so if have:
>
> 1
>
> Hello
>
>
>
> builders
>
> builders
>
> buildings
>
> buildings
>
> construction
>
> construction
>
> green
>
> green
>
>
>
>
>
> It just shows up:
>
>
>
>
>
> 1
>
> 1
>
> 1
>
> 1

>
>
>
> I'm not sure if this a solr-php-client related question (as faceting
>
> in other fields works fine) or more towards Solr functionality
>
> itlsef...
>
> Would appreciate the help
>
>
>
> --
>
> You received this message because you are subscribed to the Google Groups "PHP Solr Client" group.
>
> To post to this group, send email to php-sol...@googlegroups.com.
>
> To unsubscribe from this group, send email to php-solr-clie...@googlegroups.com.
>
> For more options, visit this group at http://groups.google.com/group/php-solr-client?hl=en.
>
>
>
>

chilakilez

unread,
May 5, 2011, 1:02:46 PM5/5/11
to PHP Solr Client
Yeah you nailed it, thanks Donovan, my approach is not within the
scope of the facet feature in Solr apparently.

On May 5, 10:05 am, donovan.jime...@gmail.com wrote:
> You can facet on multivalued fields, but i don't think its going to return  
> results like you want. The facet counts are the number of documents that  
> both match the query and have a particular field term (no matter how many  
> times). It won't return the number of times a term occurs over all those  
> documents like I think you're expecting in your example. I'm not sure of  
> any search component that currently does that. You might want to ask the  
> solr user lists:http://lucene.apache.org/solr/mailing_lists.html
>
> Hope I understood your question and was helpful,
> - Donovan
>
Reply all
Reply to author
Forward
0 new messages