tags:

views:

41

answers:

2

I'm looking into using Solr for a project where we have some specific faceting requirements. From what I've learned, Solr provides range-based facets, where Solr can provide facets of different value-ranges or date-ranges, e.i. field values are "grouped" and aggregated into different bins.

I would like to do something similar, but I want to create a custom function that maps field values to my specific facets, so that each field value is evaluated using a function to see which facet it belongs to. myFacet = myFacetMapper(fieldValue)

Its sort of a more advanced version of range-facets, but where values are mapped using a custom function rather than just into different bins.

Does anyone know if this is possible and where to start?

A: 

Create another field with value = myFacetMapper(field) , then do normal faceting on that field.

kaka
The thing is that i want the mapping function to be dynamic (ideally based on the query), so I would like to do it a query time, not at indexing time. Is that how range-facets are implemented? Is the range actually stored, or can you query out arbritary ranges for each query?
Bjorn
@Bjorn: kaka is correct, in Solr you usually do this kind of things at index-time, not at query-time.
Mauricio Scheffer
But i reeeeaaaaally need to do this at query time :-)From an algorithmical point of view, what I want to do is hook up at the step where the actual aggregation is performed. Since this probably (..?...see my comment above) is done by Solr when calculating facet ranges, It aught to be possible without too much trouble. Instead of mapping 1,2,3,4 -> bin[1-4] I would like to inject a custom function.
Bjorn
A: 

I would look into using SimpleFacets to implement your logic. Then you embed it inside a SearchComponent, that you can register into your solrconfig. Look at the code of FacetComponent for an example.

Pascal Dimassimo