Given the following indices:
{
id: 1,
distance: [4, 10]
},
{
id: 2,
distance: [1, 2]
},
{
id: 3,
distance: [9, 10]
}
After enabling faceting on distance to be able to apply numerical filters on it, I want to apply additional filtering on a derived attribute that I'll call distance_range. It derives its value through custom logic on an existing attribute for example:
// In JS:
distance_range: Math.floor(( distance - 0.5 ) / 5) * 5 + "-" + Math.ceil(( distance ) / 5) * 5
Which would transform each distance number into a range "0-5", "5-10", etc.
{
id: 1,
distance: [4, 10],
distance_range: ["0-5", "5-10"]
},
{
id: 2,
distance: [1, 2]
distance_range: ["0-5"]
},
{
id: 3,
distance: [9, 10]
distance_range: ["5-10"]
}
What is the best way to arrive at such an index? Do I have the process the data beforehand, or does algolia have such a feature to transform attributes on the fly?