Multi search API

edit

Multi search API

edit

Submit multiple searches and receive multiple sets of results with metadata.

GET /api/as/v1/engines/<engine_name>/multi_search
POST /api/as/v1/engines/<engine_name>/multi_search

Request body

edit
queries (required)

Array of objects, where each object represents a search API request body.

The length of the array must be less than or equal to 10.

Within a single request, you are submitting multiple searches. The analytics APIs therefore count each search within the request as a separate query.

Response body

edit

Array of objects, where each object represents a search API response body.

Examples

edit

Request:

curl -X POST 'http://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/multi_search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-soaewu2ye6uc45dr8mcd54v8' \
-d '{
  "queries": [
    {"query": "california"},
    {"query": "florida"}
  ]
}'

Response:

[
  # First query result
  {
    "meta": {
      "alerts": [],
      "warnings": [],
      "page": {
        "current": 1,
        "size": 10,
        "total_pages": 1,
        "total_results": 4
      }
    },
    "results": [
      {
        "nps_link": {
          "raw": "https://www.nps.gov/yose/index.htm"
        },
        "id": {
          "raw": "park_yosemite"
        },
        "visitors": {
          "raw": 5028868
        },
        "title": {
          "raw": "Yosemite"
        },
        "date_established": {
          "raw": "1890-10-01T05:00:00+00:00"
        },
        "world_heritage_site": {
          "raw": "true"
        },
        "_meta": {
          "score": 7543316
        },
        "description": {
          "raw": "Yosemite features sheer granite cliffs, exceptionally tall waterfalls, and old-growth forests at a unique intersection of geology and hydrology. Half Dome and El Capitan rise from the park's centerpiece, the glacier-carved Yosemite Valley, and from its vertical walls drop Yosemite Falls, one of North America's tallest waterfalls at 2,425 feet (739 m) high. Three giant sequoia groves, along with a pristine wilderness in the heart of the Sierra Nevada, are home to a wide variety of rare plant and animal species."
        },
        "states": {
          "raw": [
            "California"
          ]
        },
        "acres": {
          "raw": 761747.5
        },
        "location": {
          "raw": "37.83,-119.5"
        },
        "square_km": {
          "raw": 3082.7
        }
      },
      # ... More documents (truncated)
    ]
  },
  # ... Second query result (truncated)
]