Come together with the global Drupal community in Rotterdam, 28 Sept – 1 Oct 2026. Sessions, contribution, connection, and Early Bird savings until 8 June.
each CCK field that has "options widgets (facets don't make sense otherwise), or fields that have specific mappings." (as per docs in apachesolr.module).
Each facet will be represented by a block, so you must enable that block in admin/build/blocks jn order to see it on your search results.
It sounds like Price is not a "select value" type of field, so it won't generate a facet. You would probably want to have a "Price Range" field of type "Select" or "Radio" and that will produce a facet. An alternative would be a Category called "Price Range" with terms for each range.
"each CCK field that has "options widgets (facets don't make sense otherwise), or fields that have specific mappings."
There is a bug (5.x-1.x-dev) which prevents mapped CCK fields (non-options) from being faceted.
In apachesolr.module this offending line: if (($row->type == 'text' && in_array($row->widget_type, array('options_select', 'options_buttons'))) || in_array($row->type, array_keys($mappings))) {
Should be changed so that it looks like: if (($row->type == 'text' && in_array($row->widget_type, array('options_select', 'options_buttons'))) || in_array($row->field_name, array_keys($mappings))) {
Otherwise the mapped fields will never be applied!
I believe a "non-option mapped" field is one where there could be an unlimited number of values entered, , i.e. a free form text field.
e.g. Your Dog's Name could end up with thousands of values.
I think the reason for excluding these is because the facet block for "Your Dog's Name" would contain thousands of "filter by" entries. An interesting idea for CCK would be to add a functions that maintains a "range" field along with free text fields.
For instance, in relation to @nquery's original question, this cool function would hook into nodeapi 'update', automatically look for the min and max of Price, and adjust the associated "Price Range" field, spreading the choices into, say 10 ranges...
Comments
Comment #1
pahariwalla commentedA facet will be created automatically for
Each facet will be represented by a block, so you must enable that block in admin/build/blocks jn order to see it on your search results.
It sounds like Price is not a "select value" type of field, so it won't generate a facet. You would probably want to have a "Price Range" field of type "Select" or "Radio" and that will produce a facet. An alternative would be a Category called "Price Range" with terms for each range.
Hope this helps.
Comment #2
nquery commentedpahariwalla,
Yes, that helped. Thank you.
I guess what really stumped me was:
There is a bug (5.x-1.x-dev) which prevents mapped CCK fields (non-options) from being faceted.
In apachesolr.module this offending line:
if (($row->type == 'text' && in_array($row->widget_type, array('options_select', 'options_buttons'))) || in_array($row->type, array_keys($mappings))) {Should be changed so that it looks like:
if (($row->type == 'text' && in_array($row->widget_type, array('options_select', 'options_buttons'))) || in_array($row->field_name, array_keys($mappings))) {Otherwise the mapped fields will never be applied!
Comment #3
asak commentedMight be a stupid question but... What's a non-option mapped CCK field?
Comment #4
pahariwalla commented@nquery, @asak
I believe a "non-option mapped" field is one where there could be an unlimited number of values entered, , i.e. a free form text field.
e.g. Your Dog's Name could end up with thousands of values.
I think the reason for excluding these is because the facet block for "Your Dog's Name" would contain thousands of "filter by" entries. An interesting idea for CCK would be to add a functions that maintains a "range" field along with free text fields.
For instance, in relation to @nquery's original question, this cool function would hook into nodeapi 'update', automatically look for the min and max of Price, and adjust the associated "Price Range" field, spreading the choices into, say 10 ranges...
Have fun !
Comment #5
JacobSingh commented