/search - Advanced search endpoint

Overview

The /search endpoint provides powerful search capabilities across multiple content types (resorts, articles, regions, resort types, weather reports) with extensive filtering, faceting, sorting, and field selection options.

Purpose

Endpoint

GET /search

Parameters

Basic search parameters

q (string, optional)

Search query term that searches across searchable fields for each content type.

Searchable fields by type:

Relevance scoring for resorts:

Examples:


index (string, optional)

Specifies which index to search. Defaults to resort index.

Allowed values:

Examples:


type (string, optional)

Specifies the content type to search. Takes precedence over index parameter.

Allowed values:

Examples:


Pagination parameters

page (integer, optional, default: 1)

Page number for pagination (1-indexed).

Examples:


size (integer, optional, default: 20)

Number of results per page.

Examples:


Filtering parameters

facet (string, optional)

Filter results by specific field values. Multiple facets can be combined using semicolon (;) separator. Multiple values within a single facet can be combined using comma (,) for OR logic.

Format: fieldName:value or fieldName:value1,value2 (OR logic) or field1:value1;field2:value2 (multiple facets)

Common facet fields:

Examples:


dateRange (string, optional)

Filter by date range using ISO 8601 date format.

Format: YYYY-MM-DD or YYYY-MM-DDTHH:mm:ssZ (pipe-separated for range)

Applies to: created_at column

Examples:


range (string, optional)

Filter by numeric or date field ranges, supports ElasticSearch-style date expressions. Multiple range filters can be combined using a semicolon (;). All filters are ANDed together.

Format:

Date expressions (relative to current time):

Supported units:

Examples:

Note: Spaces in date expressions may be URL-encoded as + signs. Multiple range filters are combined using AND logic.


exists (string, optional)

Filter results where a specific field exists and is not null/empty.

Behavior:

Examples:


include (string, optional)

Include only specific IDs in results (comma-separated).

Uses primary ID field:

Examples:


exclude (string, optional)

Exclude specific IDs from results (comma-separated).

Uses same ID fields as include

Examples:


powderAlarm (boolean, optional)

Filter resorts or weather reports with fresh powder snow conditions.

Applies to: resort and weather_report types only

Behavior:

Examples:


Sorting parameters

sort (string, optional, default: "created_at:desc")

Sort results by field name and direction.

Format: fieldName:direction

Direction:

Examples:


Response filtering parameters

sourceFields (string, optional)

Return only specific fields from the _source object using dot notation (comma-separated).

Purpose: Optimize response payload size by requesting only needed fields

Supports nested field selection using dot notation.

Examples:


Response format

Success response structure

{
  "took": 1,
  "timed_out": false,
  "hits": {
    "total": 123,
    "hits": [
      {
        "_index": "fnugg_resort",
        "_type": "resort",
        "_id": "14",
        "_version": 1,
        "found": true,
        "_source": {
          "id": 14,
          "name": "Trysil",
          "description": "Norges største alpinområde...",
          "location": {
            "lat": 61.315,
            "lon": 12.268
          },
          "resort_open": true,
          "conditions": {
            "combined": {
              "top": {
                "snow": {
                  "depth": 120
                },
                "powder_alarm": true
              }
            }
          }
          // ... more fields
        }
      }
      // ... more results
    ]
  },
  "aggregations": {
    "snowfall_last_week": {
      "doc_count": 10,
      "zone": {
        "doc_count_error_upper_bound": 0,
        "sum_other_doc_count": 0,
        "buckets": [
          {
            "key": "top",
            "doc_count": 10,
            "sum": {
              "value": 45.0
            }
          }
        ]
      }
    },
    "snowfall_last_five_months": {
      "doc_count": 150,
      "zone": {
        "doc_count_error_upper_bound": 0,
        "sum_other_doc_count": 0,
        "buckets": [
          {
            "key": "top",
            "doc_count": 75,
            "sum": {
              "value": 2340.5
            }
          },
          {
            "key": "bottom",
            "doc_count": 75,
            "sum": {
              "value": 1820.0
            }
          }
        ]
      }
    },
    "site": {
      "doc_count_error_upper_bound": 0,
      "sum_other_doc_count": 0,
      "buckets": []
    },
    "resort_type": {
      "doc_count_error_upper_bound": 0,
      "sum_other_doc_count": 0,
      "buckets": []
    },
    "zone": {
      "doc_count_error_upper_bound": 0,
      "sum_other_doc_count": 0,
      "buckets": []
    },
    "type": {
      "doc_count_error_upper_bound": 0,
      "sum_other_doc_count": 0,
      "buckets": []
    },
    "region": {
      "doc_count_error_upper_bound": 0,
      "sum_other_doc_count": 0,
      "buckets": []
    }
  },
  "total": 123
}

Response fields

Individual result fields

Each result in hits.hits contains:


Aggregations

The aggregations object provides statistical summaries and grouped data for search results. The structure and content depends on the search type and parameters.

Snowfall aggregations (weather_report type only)

When searching type=weather_report parameter, the response includes snowfall statistics grouped by weather zone (top/bottom):

snowfall_last_week

Total snowfall in the past 7 days, grouped by zone.

Structure:

Example:

{
  "snowfall_last_week": {
    "doc_count": 10,
    "zone": {
      "buckets": [
        {
          "key": "top",
          "doc_count": 10,
          "sum": { "value": 45.0 }
        }
      ]
    }
  }
}

snowfall_last_five_months

Total snowfall in the past 5 months, grouped by zone. Uses the same structure as snowfall_last_week.

Legacy aggregations (deprecated)

The following aggregation fields are maintained for backward compatibility with the previous ElasticSearch-based API but contain empty buckets:

These fields always return empty bucket arrays:

{
  "site": {
    "doc_count_error_upper_bound": 0,
    "sum_other_doc_count": 0,
    "buckets": []
  }
}

Note: those are present only to maintain API response structure compatibility.


Example requests

GET /search?q=Trysil

Searches for resorts matching "Trysil" with relevance scoring.


Open resorts with fresh powder

GET /search?type=resort&facet=resort_open:1&powderAlarm=1&sort=conditions.combined.top.snow.depth_terrain:desc

Finds all open resorts with fresh powder, sorted by snow depth.


Resorts opening next week

GET /search?type=resort&range=resort_opening_date:now|now+1w&sort=resort_opening_date:asc

Finds resorts opening within the next 7 days, sorted by opening date.


Blog posts from 2024

GET /search?index=blog&type=blog_post&dateRange=2024-01-01|2024-12-31&size=50

Searches all blog posts created in 2024, returning 50 results per page.


Weather reports with snowfall aggregations

GET /search?type=weather_report&facet=site:24&size=10

Fetches weather reports for resort site_id 24, includes snowfall aggregations by zone for the past week and 5 months.


Resorts in specific region with minimal response

GET /search?type=resort&facet=region:Oslo&sourceFields=name,location.lat,location.lon,resort_open

Finds resorts in Oslo region, returning only name, coordinates, and open status.


Resorts with deep snow

GET /search?type=resort&range=conditions.combined.top.snow.depth_terrain:100|200&facet=resort_open:1

Finds open resorts with snow depth between 100-200cm at the top.


GET /search?q=familie&type=resort&facet=resort_open:1;resort_type:Alpint&range=lifts.open:5&exists=slope_map&sourceFields=name,lifts,slopes,location&size=10&page=1

Searches for family-friendly open alpine resorts with at least 5 open lifts and a slope map, returning name, lifts, slopes, and location for 10 results.


Multiple facet values with OR logic

GET /search?type=resort&facet=resort_type:Alpint,Langrenn,Familie&facet=resort_open:1

Finds open resorts that are Alpint OR Langrenn OR Familie type.


Use cases

  1. Find open ski resorts: type=resort&facet=resort_open:1
  2. Powder alert search: type=resort&powderAlarm=1&facet=resort_open:1
  3. Search by location: Use with /geodata/getnearest to get nearby resort IDs, then search with include parameter
  4. Resort comparison: Use include parameter with multiple IDs and sourceFields to get specific data
  5. Content discovery: Search blog posts with index=blog&type=blog_post&q=<term>
  6. Opening season planning: Use range=resort_opening_date:now|now+3M to find resorts opening in next 3 months
  7. Snow condition monitoring: Filter by range=conditions.combined.top.snow.depth_terrain and enable powderAlarm
  8. Snowfall statistics: Fetch weather reports with type=weather_report&facet=site:X to get snowfall aggregations by zone

Notes