Rotary cut can work.
Say you have fields: cityId, cityName, country
Make a reference face by city identifier, city name using query parameters:
facet.pivot=cityId,cityName
At the first level, as a standard face, you will receive each city identifier. But on the second level you will get the name of each city. Given that each city identifier will have only one name, you can simply read the name of each city from the next facet level (under the pivot element in XML).
<lst name="facet_pivot"> <arr name="cityId,city"> <lst> <str name="field">cityId</str> <str name="value">1</str> <int name="count">1</int> <arr name="pivot"> <lst> <str name="field">city</str> <str name="value">berlin</str> <int name="count">1</int> </lst> </arr> </lst> <lst> <str name="field">cityId</str> <str name="value">2</str> <int name="count">1</int> <arr name="pivot"> <lst> <str name="field">city</str> <str name="value">berlin</str> <int name="count">1</int> </lst> </arr> </lst> <lst> <str name="field">cityId</str> <str name="value">3</str> <int name="count">1</int> <arr name="pivot"> <lst> <str name="field">city</str> <str name="value">melbourne</str> <int name="count">1</int> </lst> </arr> </lst> </arr> </lst>
Basically, if the identifier is unique, you are guaranteed to have only one pivot value at the second level.
Optionally, if you want to group your “Berlins” together, just change the rotation order of the face and do this:
facet.pivot=cityName,cityId
and you will get “Berlin” on the first level and, possibly, several identifiers on the second level (and as a bonus you can add a third level country so that you can read the country for each city from the third level).
prunge
source share