I have created a views filter handler that extends apachesolr_views allowing it to filter results by numeric fields. To use this you must already have numeric fields in the solr index. The fields must be of type: 'number_decimal', 'number_float', 'formatted_decimal' or 'formatted_float'.
What this provides:
- Allows admins to build views that restrict search results by numeric fields
- Includes all operators <, <=, =, !=, >=, >, between, not between
- Allows admins to expose the filter so that end user can input values to limit results
- Form values can be optional
- Form values validated numeric
e.g. You can create an exposed filter for Car Horsepower using between operator. This provides the end user with a form where they can specify the minimum and maximum horsepower. If maximum value is omitted then it will return all results that are greater than the minimum (and vice versa for omitted minimum).
Tested all operators on all field types. I have been using this for months but only had time to build patch now. Would appreciate if this could be included into dev.
Comment | File | Size | Author |
---|---|---|---|
#1 | apachesolr_views_numeric_filter_handler-1321690-1.patch | 935 bytes | tinker |
#1 | apachesolr_views_handler_filter_numeric.inc_.txt | 2.92 KB | tinker |
Comments
Comment #1
tinker CreditAttribution: tinker commentedRemove .txt extension from apachesolr_views_handler_filter_numeric.inc.txt (can't attach .inc file)
BTW this also extends the numeric argument handler to use more numeric fields.
Comment #2
rjbrown99 CreditAttribution: rjbrown99 commentedIs this a duplicate of #728088: Add support for CCK Decimal fields and Numeric Facets?
Comment #3
tinker CreditAttribution: tinker commentedNo this is not a duplicate. The post you mention exposes the fields for display in views but does not provide a handler to filter the results or expose filters so that user's can search numeric fields.
The only thing it changes in existing Apache Solr View code is extending types to include 'number_float', 'formatted_decimal', 'formatted_float'. The filter handler is all new functionality.
Comment #4
rjbrown99 CreditAttribution: rjbrown99 commentedThanks for this, had a use for it and it works beautifully. Just a note to others - I had to index fields as tis* and not is* to make the ranges work correctly. If you are having problems try using a tis field.