Retrieve additional attribute values of a facet

Hello,

I’ve got a facet query that will correctly retrieve ‘Room Types’ from an Indices.

However, I need to get additional information about the returned facets.
For example, i need to turn this:

"facets": {
  "room_tyes": {
    "standard": 12,
    "deluxe": 10
  }
}

Into something like this:

"facets": {
  "room_tyes": {
    "standard": {
      "count": 12,
      "price": {
        "min": 123,
        "max": 890
      }
    "deluxe": {
      "count": 12,
      "price": {
        "min": 123,
        "max": 890
      }
    }
  }
}

Is this possible through a facet query? Or will I need to do multiple calls to get facets per room type?

I’m using: algoliasearch
and my query looks something like this:

index.search({
  facets: [
    "contracts",
    "beds",
    "occupancy",
    "floor",
    "room_tyes"
  ],
  facetQuery: "",
  maxFacetHits: 100,
  query: "2019 / 20"
},
function(err, content) {
  if (err) {
    this.handleError(err);
    return reject(err);
  }

  resolve(content.facets);
}

Any help would be great. I’ve tried to use grouping and adding Price as an additional facet but each Room Type has its own set of prices so I can’t use that…

Thanks for any help you guys can give.

Lew.

Hi there, to achieve what you want you must have different price attributes for each room type inside the room record.

For example standard_price: 50, double_price: 100.

Doing so you will be able to get the price breakdown per room type. Still you will not receive a hierarchical object with those values, you will receive a flat structure always!

I hope you’ll be able to use that, thanks!

Hi vvo,
Thanks for your response.

The thing that should have mentioned to begin with is that each room - regardless of type, will have different pricing.
For example:

'Room A'
{
  "price": 331,
  "room_type": "standard",
  ...
}

'Room B'
{
  "price": 290,
  "room_type": "standard",
  ...
}

'Room C'
{
  "price": 400,
  "room_type": "deluxe",
  ...
}

etc...

The goal is to create a Category page, such as:

Standard - From £290
Deluxe - From £400

Where I can show the ‘From’ price for each category.

I can get the data by doing a Price Facet search on ‘room_type:standard’ and then another one on ‘room_type:deluxe’

But that means that the site can end up doing 10 Algolia Facet calls per page load to get this data. Whereas I’m asking if it’s possible to do it in one.

Thanks,

Lew.