Thanks Kellen
Let me explain my search use case.
Goal
Assuming we are collecting food habits of different people. So we build a form where a user can input basic details and select their favorite foods. The favorite food selection is a hierarchical list of checkbox (same as the options list I have given in my main post). Our target is to search users with hierarchical facets filter on favorite food field. So we can filter the search results from higher level to lower level.
In SwiftType documentation I found an example of single value hierarchy as I given the reference earlier. So I followed the same data schema as below -
"id": text,
"email": text,
"dimension1": text,
"dimension2": text,
"dimension3": text
Now consider the below data we got from user. And we stored the food choice in different dimension as per hierarchy level.
[
{
"id": "user1",
"email": "a@a.com",
"dimension1": ["Vegetables", "Fruits", "Meats and Poultry"],
"dimension2": ["Tomato", "Pumpkin", "Apple", "Lean meats"],
"dimension3": ["Beef"]
},
{
"id": "user2",
"email": "b@b.com",
"dimension1": ["Vegetables", "Fruits"],
"dimension2": ["Carrot", "Pumpkin", "Banana"]
}
]
Now we query on this data with facets on "dimension1"
``
{
"query": "",
"facets": {
"dimension1": [{ "type": "value"}]
}
}
With results we got the below facets
...
"facets": {
"dimension1": [
{
"type": "value",
"data": [
{
"value": "Fruits",
"count": 2
},
{
"value": "Vegetables",
"count": 2
},
{
"value": "Meats and Poultry",
"count": 1
}
]
}
]
}
...
We filter the result set selecting facet "Vegetables" and query for next level facets -
{
"query": "",
"facets": {
"dimension2": [{ "type": "value"}]
},
"filters": {
"dimension1": ["Vegetables"]
}
}
In response we got the below facets set
...
"facets": {
"dimension2": [
{
"type": "value",
"data": [
{
"value": "Pumpkin",
"count": 2
},
{
"value": "Apple",
"count": 1
},
{
"value": "Banana",
"count": 1
},
{
"value": "Carrot",
"count": 1
},
{
"value": "Lean meats",
"count": 1
},
{
"value": "Tomato",
"count": 1
}
]
}
]
}
...
And here comes the problem.
Now from this returned facets how can we figure out which are the second level facets of "Vegetables" in the hierarchy?
Any idea how we can solve this problem?
I wonder if we could apply filter on facets query also!
Thanks,
Abhishek