I'm trying to perform faceting based on a dynamic value. Basically I want identical behavior to the def
function, but that doesn't seem to be available with faceting.
Consider these two "products":
{
"id":"product1",
"defaultPrice":19.99,
"overridePrice":14.99
},
{
"id":"product2",
"defaultPrice":49.99
}
I want to add that overridePrice
is just an example. The actual field is a dynamic value that will depend on what context a search is performed in, and there may be many overridden prices, so I can't just derive price
at index time.
For the response, I'm doing something like this for fl
:
fl=price:def(overridePrice, defaultPrice)
and using the same def
function to perform sorting on price
. This works fine.
So now I want to apply the same logic to facets. I've tried using json.facet
, which seemed like it would work:
json.facet={
price: "def(overridePrice, defaultPrice)"
}
I've tried other variations as well, such as using field:def(overridePrice, defaultPrice)
as well as field:price
, but def
doesn't seem to be an available function for faceting, and the price
derived field is not available when faceting.
So the question: How can I perform faceting based on a default field like I'm doing for fl
and sorting? Will this require a custom aggregation function, or is there a clever way I can do this without a custom function? It would be much more preferable to be able to do this with built-in Solr functionality.