Skip to main content

Faceting

Faceting, also known as faceted search, is a technique that allows users to filter and browse large datasets based on various attributes or categories. Faceted search aggregates terms and/or ranges and then applies filters based on them to narrow your search results.

Consider the following query for offers only with departureCity Gdańsk.

query {
search (
countryCode: PL,
languageCode: PL,
filters: {
departureCity: ["Gdańsk"]
}
pagination: {
offset: 0,
limit: 1
}
) {
offers {
id
name
}
facets {
countrySourceName {
count
countOffers
value
minPrice
maxPrice
avgPrice
medianPrice
}
}
}
}

Sample output from executing the graphql query above:

{
"data": {
"search": {
"offers": [
{
"id": "169",
"name": "ANDALUCIA SPA & LEISURE Villa"
}
],
"facets": {
"countrySourceName": [
{
"count": 612,
"countOffers": 6,
"value": "Polska",
"minPrice": 1000,
"maxPrice": 5500,
"avgPrice": 5225,
"medianPrice": 5500
},
{
"count": 308,
"countOffers": 1,
"value": "Malediwy",
"minPrice": 11642,
"maxPrice": 11642,
"avgPrice": 11642,
"medianPrice": 11642
},
{
"count": 266,
"countOffers": 2,
"value": "Egipt",
"minPrice": 2227,
"maxPrice": 3000,
"avgPrice": 2546,
"medianPrice": 2227
}
]
}
}
}
}

The output of the query returns unique vaules that occur in the field countrySourceName:

  • count - is the number of occurrences of a given value in the result set (in our case number of all trips)
  • countOffers - is the number of occurences of a given value for unique offers in the results set
  • value - is the instance of the value
  • minPrice - is the minimal price for all prices in a given result set
  • maxPrice - is the maximal price for all prices in a given result set
  • avgPrice - is the average price for all prices in a given result set
  • medianPrice - is the median price for all prices in a given result set

By default, facet values are sorted by frequency.

Adults

The following example retrieves facet values, counts and price statistics for the adults attribute.

query {
search(countryCode: PL, languageCode: PL) {
facets {
adults {
count
countOffers
value
maxPrice
minPrice
avgPrice
medianPrice
}
}
}
}

Departure dates

The following example shows how to retrieve facets on departureDate field. You can obtain dates found in the search result using input dailyPrices or get months of the departure date using input monthly.

query {
search(
countryCode: PL,
languageCode: PL
filters: {
countrySourceName: ["Egipt"]
}
) {
facets {
departureDate {
min
max
dailyPrices {
minPrice
maxPrice
avgPrice
medianPrice
day
year
month
value
}
monthly {
minPrice
maxPrice
avgPrice
medianPrice
year
month
value
}
}
}
}
}

Sample output from executing the graphql query above:

{
"data": {
"search": {
"facets": {
"departureDate": {
"min": "2024-09-12",
"max": "2025-09-08",
"dailyPrices": [
{
"minPrice": 4500,
"maxPrice": 4500,
"avgPrice": 4500,
"medianPrice": 4500,
"day": 12,
"year": 2024,
"month": 9,
"value": "2024-09-12"
},
{
"minPrice": null,
"maxPrice": null,
"avgPrice": null,
"medianPrice": null,
"day": 13,
"year": 2024,
"month": 9,
"value": "2024-09-13"
}
],
"monthly": [
{
"minPrice": 2227,
"maxPrice": 5900,
"avgPrice": 2813,
"medianPrice": 2227,
"year": 2024,
"month": 9,
"value": "2024-09-11"
},
{
"minPrice": 2227,
"maxPrice": 4500,
"avgPrice": 2682,
"medianPrice": 2227,
"year": 2024,
"month": 10,
"value": "2024-10-01"
},
{
"minPrice": 2227,
"maxPrice": 4500,
"avgPrice": 2672,
"medianPrice": 2227,
"year": 2024,
"month": 11,
"value": "2024-11-01"
}
]
}
}
}
}
}

The output of the query returns unique vaules that occur in the field departureDate:

  • min - is the minimal departure date found in the given result set
  • max - is the maximal departure date found in the given result set
  • dailyPrices - list of departure dates
  • monthly - list of months for departure dates

For each dailyPrices:

  • minPrice - is the minimal price based on all offer prices with a given departure date
  • maxPrice - is the maximal price based on all offer prices with a given departure date
  • avgPrice - is the average price based on all offer prices with a given departure date
  • medianPrice - is the median price based on all offer prices with a given departure date
  • value - is the vaule of departure date
  • day - day of the departure date
  • month - the numeber of month of the departure date
  • year - the year of the departure date

For each monthly:

  • minPrice - is the minimal price based on all offer prices with a given month of departure
  • maxPrice - is the maximal price based on all offer prices with a given month of departure
  • avgPrice - is the average price based on all offer prices with a given month of departure
  • medianPrice - is the median price based on all offer prices with a given month of departure
  • value - is the value of month of departure date in format YYYY-MM-01
  • month - the numeber of month of the departure date
  • year - the year of the departure date

Destination

The following example retrieves hierarchical facets for destination categories: countrySourceName, regionSourceName, citySourceName.

Hierarchical location

query {
search (
countryCode: PL,
languageCode: PL,
) {
facets {
countrySourceName {
count
countOffers
value
minPrice
maxPrice
avgPrice
medianPrice
regionSourceName {
count
countOffers
value
minPrice
maxPrice
avgPrice
medianPrice
citySourceName {
count
countOffers
value
minPrice
maxPrice
avgPrice
medianPrice
}
}
}
}
}

Country

The following examples retrive facets for countrySourceName or countrySourceId field.

query {
search(countryCode: PL, languageCode: PL) {
facets {
countrySourceName {
count
countOffers
value
minPrice
maxPrice
avgPrice
medianPrice
}
}
}
}
query {
search(countryCode: PL, languageCode: PL) {
facets {
countrySourceId {
count
countOffers
value
minPrice
maxPrice
avgPrice
medianPrice
}
}
}
}

Region

The following examples retrive facets for regionSourceName or regionSourceId field.

query {
search(countryCode: PL, languageCode: PL) {
facets {
regionSourceName {
count
countOffers
value
minPrice
maxPrice
avgPrice
medianPrice
}
}
}
}
query {
search(countryCode: PL, languageCode: PL) {
facets {
regionSourceId {
count
countOffers
value
minPrice
maxPrice
avgPrice
medianPrice
}
}
}
}

City

The following examples retrive facets for citySourceName or citySourceId field.

query {
search(countryCode: PL, languageCode: PL) {
facets {
citySourceName {
count
countOffers
value
minPrice
maxPrice
avgPrice
medianPrice
}
}
}
}
query {
search(countryCode: PL, languageCode: PL) {
facets {
citySourceId {
count
countOffers
value
minPrice
maxPrice
avgPrice
medianPrice
}
}
}
}

Offer type

The following example retrieves facets for offerType field.

query {
search(countryCode: PL, languageCode: PL) {
facets {
offerType {
count
countOffers
value
minPrice
maxPrice
avgPrice
medianPrice
}
}
}
}

Property category

The following examples retrieve facets for property category field.

Property category

query {
search(countryCode: PL, languageCode: PL) {
facets {
propertyCategory {
count
countOffers
value
minPrice
maxPrice
avgPrice
medianPrice
}
}
}
}

Property category range

The following example retrieve facets for offerType field.

query {
search(
countryCode: PL,
languageCode: PL
) {
facets {
propertyCategoryRange {
min
max
values {
count
countOffers
value
minPrice
maxPrice
avgPrice
medianPrice
}
}
}
}
}

Transport type

The following example retrieves facets for transportType field.

query {
search(countryCode: PL, languageCode: PL) {
facets {
transportType {
count
countOffers
value
minPrice
maxPrice
avgPrice
medianPrice
}
}
}
}

Departure city

The following example retrieves facets for departureCity field.

query {
search(countryCode: PL, languageCode: PL) {
facets {
departureCity {
count
countOffers
value
minPrice
maxPrice
avgPrice
medianPrice
}
}
}
}

Period

The following example retrieves facets for period field.

Period

query {
search(countryCode: PL, languageCode: PL) {
facets {
period {
count
countOffers
value
minPrice
maxPrice
avgPrice
medianPrice
}
}
}
}

Period Range

query {
search(countryCode: PL, languageCode: PL) {
facets {
periodRange {
max
min
values {
count
countOffers
value
minPrice
maxPrice
avgPrice
medianPrice
}
}
}
}
}

Maintenances

The following examples retrive facets for maintenanceSourceName, maintenanceName, maintenanceSourceCode or maintenanceCode field.

query {
search(countryCode: PL, languageCode: PL) {
facets {
maintenanceSourceName {
count
countOffers
value
minPrice
maxPrice
avgPrice
medianPrice
}
}
}
}
query {
search(countryCode: PL, languageCode: PL) {
facets {
maintenanceName {
count
countOffers
value
minPrice
maxPrice
avgPrice
medianPrice
}
}
}
}
query {
search(countryCode: PL, languageCode: PL) {
facets {
maintenanceSourceCode {
count
countOffers
value
minPrice
maxPrice
avgPrice
medianPrice
}
}
}
}
query {
search(countryCode: PL, languageCode: PL) {
facets {
maintenanceCode {
count
countOffers
value
minPrice
maxPrice
avgPrice
medianPrice
}
}
}
}

Rooms

The following examples retrive facets for roomSourceName, roomName, roomSourceCode or roomCode field.

query {
search(countryCode: PL, languageCode: PL) {
facets {
roomSourceName {
count
countOffers
value
minPrice
maxPrice
avgPrice
medianPrice
}
}
}
}
query {
search(countryCode: PL, languageCode: PL) {
facets {
roomName {
count
countOffers
value
minPrice
maxPrice
avgPrice
medianPrice
}
}
}
}
query {
search(countryCode: PL, languageCode: PL) {
facets {
roomSourceCode {
count
countOffers
value
minPrice
maxPrice
avgPrice
medianPrice
}
}
}
}
query {
search(countryCode: PL, languageCode: PL) {
facets {
roomCode {
count
countOffers
value
minPrice
maxPrice
avgPrice
medianPrice
}
}
}
}

Price

The following example retrieves facet for prices in a given range 1 000 - 11 000. It defines the gap between successive ranges.

query {
search(countryCode: PL, languageCode: PL) {
facets {
price {
max
min
ranges(config: { start: 1000, end: 11000, gap: 2000 }) {
max
min
}
}
}
}
}

Sample output from executing the graphql query above:

{
"data": {
"search": {
"facets": {
"price": {
"max": 35800,
"min": 1000,
"ranges": [
{
"max": null,
"min": null,
"count": 0
},
{
"max": 2999,
"min": 1000,
"count": 4374
},
{
"max": 4850,
"min": 3000,
"count": 6153
},
{
"max": 6964,
"min": 5000,
"count": 5130
},
{
"max": 8000,
"min": 7000,
"count": 229
},
{
"max": 10500,
"min": 9000,
"count": 491
},
{
"max": 35800,
"min": 11000,
"count": 3259
}
]
}
}
}
}
}

The output of the query returns:

  • min - is the minimal price for all prices in a given result set
  • max - is the maximal price for all prices in a given result set
  • ranges - list of price ranges between values 1000 - 11000. Ranges are returned every 2000 from 1000 to 11000.

For each range:

  • min - is the lower bound of the range
  • max - is the upper bould of the range (the maximal price in the range)
  • count -is the number of occurences of prices within the given range

Semantic Category

Accommodation

query {
search(countryCode: PL, languageCode: PL) {
facets {
semanticCategoryAccommodation {
count
countOffers
value
minPrice
maxPrice
avgPrice
medianPrice
}
}
}
}

Activity

query {
search(countryCode: PL, languageCode: PL) {
facets {
semanticCategoryActivity {
count
countOffers
value
minPrice
maxPrice
avgPrice
medianPrice
}
}
}
}

Board Type

query {
search(countryCode: PL, languageCode: PL) {
facets {
semanticCategoryBoardType {
count
countOffers
value
minPrice
maxPrice
avgPrice
medianPrice
}
}
}
}

Cuisine

query {
search(countryCode: PL, languageCode: PL) {
facets {
semanticCategoryCuisine {
count
countOffers
value
minPrice
maxPrice
avgPrice
medianPrice
}
}
}
}

Hotel Amenities

query {
search(countryCode: PL, languageCode: PL) {
facets {
semanticCategoryHotelAmenities {
count
countOffers
value
minPrice
maxPrice
avgPrice
medianPrice
}
}
}
}

Hotel Attractions

query {
search(countryCode: PL, languageCode: PL) {
facets {
semanticCategoryHotelAttractions {
count
countOffers
value
minPrice
maxPrice
avgPrice
medianPrice
}
}
}
}

Hotel Type

query {
search(countryCode: PL, languageCode: PL) {
facets {
semanticCategoryHotelType {
count
countOffers
value
minPrice
maxPrice
avgPrice
medianPrice
}
}
}
}

Localization

query {
search(countryCode: PL, languageCode: PL) {
facets {
semanticCategoryLocalization {
count
countOffers
value
minPrice
maxPrice
avgPrice
medianPrice
}
}
}
}

Nature

query {
search(countryCode: PL, languageCode: PL) {
facets {
semanticCategoryNature {
count
countOffers
value
minPrice
maxPrice
avgPrice
medianPrice
}
}
}
}

Offer Type

query {
search(countryCode: PL, languageCode: PL) {
facets {
semanticCategoryOfferType {
count
countOffers
value
minPrice
maxPrice
avgPrice
medianPrice
}
}
}
}

Other

query {
search(countryCode: PL, languageCode: PL) {
facets {
semanticCategoryOther {
count
countOffers
value
minPrice
maxPrice
avgPrice
medianPrice
}
}
}
}

Room Amenities

query {
search(countryCode: PL, languageCode: PL) {
facets {
semanticCategoryRoomAmenities {
count
countOffers
value
minPrice
maxPrice
avgPrice
medianPrice
}
}
}
}

Room Type

query {
search(countryCode: PL, languageCode: PL) {
facets {
semanticCategoryRoomType {
count
countOffers
value
minPrice
maxPrice
avgPrice
medianPrice
}
}
}
}

Skiing

query {
search(countryCode: PL, languageCode: PL) {
facets {
semanticCategorySkiing {
count
countOffers
value
minPrice
maxPrice
avgPrice
medianPrice
}
}
}
}

Transportation

query {
search(countryCode: PL, languageCode: PL) {
facets {
semanticCategoryTransportation {
count
countOffers
value
minPrice
maxPrice
avgPrice
medianPrice
}
}
}
}

Trip Attractions

query {
search(countryCode: PL, languageCode: PL) {
facets {
semanticCategoryTripAttractions {
count
countOffers
value
minPrice
maxPrice
avgPrice
medianPrice
}
}
}
}

Trip Type

query {
search(countryCode: PL, languageCode: PL) {
facets {
semanticCategoryTripType {
count
countOffers
value
minPrice
maxPrice
avgPrice
medianPrice
}
}
}
}

Touroperator

Touroperator Code

query {
search(countryCode: PL, languageCode: PL) {
facets {
touroperatorCode {
count
countOffers
value
minPrice
maxPrice
avgPrice
medianPrice
}
}
}
}

Touroperator Name

query {
search(countryCode: PL, languageCode: PL) {
facets {
touroperatorName {
count
countOffers
value
minPrice
maxPrice
avgPrice
medianPrice
}
}
}
}
If you don't find example

You can explore the available facets options and other fields on our Demo Search Playground. Visit the Docs tab for detailed information on these options.