search mobile facets autocomplete spellcheck crawler rankings weights synonyms analytics engage api customize documentation install setup technology content domains user history info home business cart chart contact email activate analyticsalt analytics autocomplete cart contact content crawling custom documentation domains email engage faceted history info install mobile person querybuilder search setup spellcheck synonyms weights engage_search_term engage_related_content engage_next_results engage_personalized_results engage_recent_results success add arrow-down arrow-left arrow-right arrow-up caret-down caret-left caret-right caret-up check close content conversions-small conversions details edit grid help small-info error live magento minus move photo pin plus preview refresh search settings small-home stat subtract text trash unpin wordpress x alert case_deflection advanced-permissions keyword-detection predictive-ai sso

Result Fields

Before beginning, consider reading the Sanitization Guide to mitigate XSS risks!


Use the result_fields parameter to specify which fields to receive in the search response and the form in which to receive them.

If the result_fields parameter is not given, the API will return the raw values for all available fields.

Raw Result Fields

Requests the exact value that was indexed.

Depending on the type of the field, this can be returned as either a string, number, or an array of strings/numbers.

Be cautious requesting raw text results on account of XSS risks!

size
optional
Length of the return value. Only can be used on text fields. Must be at least 20; defaults to the entire text field. If given for a different field type other than text, it will be silently ignored.
Example - Specifying result_fields of title and description.
curl -X GET 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-soaewu2ye6uc45dr8mcd54v8' \
-d '{
  "query": "everglade",
  "result_fields": {
    "title": {
      "raw": {}
    },
    "description": {
      "raw": {
        "size": 50
      }
    }
  }
}'
Example Response
{
  "meta": {
    "warnings": [],
    "page": {
      "current": 1,
      "total_pages": 1,
      "total_results": 3,
      "size": 10
    },
    "request_id": "2442cc5b3bd956b0339d5e604b562060"
  },
  "results": [
    {
      "title": {
        "raw": "Everglades"
      },
      "description": {
        "raw": "The Everglades are the largest tropical wilderness"
      },
      "id": {
        "raw": "park_everglades"
      },
      "_meta": {
        "score": 1.0028129
      }
    },
    {
      "title": {
        "raw": "Voyageurs"
      },
      "description": {
        "raw": "This park protecting four lakes near the Canada–US"
      },
      "id": {
        "raw": "park_voyageurs"
      },
      "_meta": {
        "score": 0.0062864386
      }
    },
    {
      "title": {
        "raw": "Wrangell–St. Elias"
      },
      "description": {
        "raw": "An over 8 million acres (32,375 km2) plot of"
      },
      "id": {
        "raw": "park_wrangell–st.-elias"
      },
      "_meta": {
        "score": 0.00437395
      }
    }
  ]
}

Example - Specifying result_fields of title and description.
import com.swiftype.appsearch.Client;
import com.swiftype.appsearch.ClientException;
import java.util.*;

Client client = new Client("host-2376rb", "search-soaewu2ye6uc45dr8mcd54v8");

String engineName = "national-parks-demo"; String query = "everglade";

Map<String, Object> title = new HashMap<>(); title.put("raw", Collections.emptyMap());

Map<String, Integer> descriptionRaw = new HashMap<>(); descriptionRaw.put("size", 50); Map<String, Object> description = new HashMap<>(); description.put("raw", descriptionRaw);

Map<String, Object> resultFields = new HashMap<>(); resultFields.put("title", title); resultFields.put("description", description);

Map<String, Object> options = new HashMap<>(); options.put("result_fields", resultFields);

try { Map<String, Object> response = client.search(engineName, query, options); System.out.println(response); } catch (ClientException e) { System.out.println(e); }

Example Response
Map<String, Object>: {
  "meta": {
    "warnings": [],
    "page": {
      "current": 1,
      "total_pages": 1,
      "total_results": 3,
      "size": 10
    },
    "request_id": "2442cc5b3bd956b0339d5e604b562060"
  },
  "results": [
    {
      "title": {
        "raw": "Everglades"
      },
      "description": {
        "raw": "The Everglades are the largest tropical wilderness"
      },
      "id": {
        "raw": "park_everglades"
      },
      "_meta": {
        "score": 1.0028129
      }
    },
    {
      "title": {
        "raw": "Voyageurs"
      },
      "description": {
        "raw": "This park protecting four lakes near the Canada–US"
      },
      "id": {
        "raw": "park_voyageurs"
      },
      "_meta": {
        "score": 0.0062864386
      }
    },
    {
      "title": {
        "raw": "Wrangell–St. Elias"
      },
      "description": {
        "raw": "An over 8 million acres (32,375 km2) plot of"
      },
      "id": {
        "raw": "park_wrangell–st.-elias"
      },
      "_meta": {
        "score": 0.00437395
      }
    }
  ]
}

Example - Specifying result_fields of title and description.
const SwiftypeAppSearchClient = require('swiftype-app-search-node')

const client = new SwiftypeAppSearchClient('host-2376rb', 'search-soaewu2ye6uc45dr8mcd54v8')

const engineName = 'national-parks-demo' const query = 'everglade'

const options = { result_fields: { title: { raw: {} }, description: { raw: { size: 50 } } } }

client .search(engineName, query, options) .then(response => console.log(response)) .catch(error => console.log(error))

Example Response
{
  "meta": {
    "warnings": [],
    "page": {
      "current": 1,
      "total_pages": 1,
      "total_results": 3,
      "size": 10
    },
    "request_id": "2442cc5b3bd956b0339d5e604b562060"
  },
  "results": [
    {
      "title": {
        "raw": "Everglades"
      },
      "description": {
        "raw": "The Everglades are the largest tropical wilderness"
      },
      "id": {
        "raw": "park_everglades"
      },
      "_meta": {
        "score": 1.0028129
      }
    },
    {
      "title": {
        "raw": "Voyageurs"
      },
      "description": {
        "raw": "This park protecting four lakes near the Canada–US"
      },
      "id": {
        "raw": "park_voyageurs"
      },
      "_meta": {
        "score": 0.0062864386
      }
    },
    {
      "title": {
        "raw": "Wrangell–St. Elias"
      },
      "description": {
        "raw": "An over 8 million acres (32,375 km2) plot of"
      },
      "id": {
        "raw": "park_wrangell–st.-elias"
      },
      "_meta": {
        "score": 0.00437395
      }
    }
  ]
}

Example - Specifying result_fields of title and description.
require 'swiftype-app-search'

host_identifier = 'host-2376rb' api_key = 'search-soaewu2ye6uc45dr8mcd54v8' client = SwiftypeAppSearch::Client.new(host_identifier: host_identifier, api_key: api_key)

engine_name = 'national-parks-demo' query = 'everglade'

options = { result_fields: { title: { raw: {} }, description: { raw: { size: 50 } } } }

begin puts client.search(engine_name, query, options) rescue SwiftypeAppSearch::ClientException => e puts e end

Example Response
{
  "meta" => {
    "warnings" => [], "page" => {
      "current" => 1, "total_pages" => 1, "total_results" => 3, "size" => 10
    }, "request_id" => "4f861a39b1250427d11cd688456c20a4"
  }, "results" => [{
    "title" => {
      "raw" => "Everglades"
    },
    "description" => {
      "raw" => "The Everglades are the largest tropical wilderness"
    },
    "id" => {
      "raw" => "park_everglades"
    },
    "_meta" => {
      "score" => 1.0028129
    }
  }, {
    "title" => {
      "raw" => "Voyageurs"
    },
    "description" => {
      "raw" => "This park protecting four lakes near the Canada–US"
    },
    "id" => {
      "raw" => "park_voyageurs"
    },
    "_meta" => {
      "score" => 0.0062864386
    }
  }, {
    "title" => {
      "raw" => "Wrangell–St. Elias"
    },
    "description" => {
      "raw" => "An over 8 million acres (32,375 km2) plot of"
    },
    "id" => {
      "raw" => "park_wrangell–st.-elias"
    },
    "_meta" => {
      "score" => 0.00437395
    }
  }]
}

Example - Specifying result_fields of title and description.
from swiftype_app_search import Client
from swiftype_app_search.exceptions import SwiftypeAppSearchError

host_identifier = 'host-2376rb' api_key = 'search-soaewu2ye6uc45dr8mcd54v8' client = Client(host_identifier, api_key)

engine_name = 'national-parks-demo' query = 'everglade'

options = { 'result_fields': { 'title': { 'raw': {} }, 'description': { 'raw': { 'size': 50 } } } }

try: print(client.search(engine_name, query, options)) except SwiftypeAppSearchError as e: print(e)

Example Response
{
    'meta': {
        ## Truncated!
    },
    'results': [
        {
            'description': {
                'raw': 'The Everglades are the largest tropical wilderness'
            },
            'id': {
                'raw': 'park_everglades'
            },
            'title': {
                'raw': 'Everglades'
            },
            '_meta': {
                'score': 1.0028129
            }
        },
        {
            'description': {
                'raw': 'This park protecting four lakes near the Canada–US'
            },
            'id': {
                'raw': 'park_voyageurs'
            },
            'title': {
                'raw': 'Voyageurs'
            },
            '_meta': {
                'score': 0.0062864386
            }
        },
        {
            'description': {
                'raw': 'An over 8 million acres (32,375 km2) plot of'
            },
            'id': {
                'raw': 'park_wrangell–st.-elias'
            },
            'title': {
                'raw': 'Wrangell–St. Elias'
            },
            '_meta': {
                'score': 0.00437395
            }
        }
    ]
}

Example - Specifying result_fields of title and description.
const client = SwiftypeAppSearch.createClient({
  hostIdentifier: 'host-2376rb',
  searchKey: 'search-soaewu2ye6uc45dr8mcd54v8',
  engineName: 'national-parks-demo'
})

const query = 'everglade'

const options = { result_fields: { title: { raw: {} }, description: { raw: { size: 50 } } } }

client .search(query, options) .then(function(response){ console.log(response) }) .catch(function(error){ console.log(error) })

Example Response
ResultList {
  "rawResults": [
    {
      ## Truncated! Same as ResultItem.data.
    },
    {
      ## Truncate! Same as ResultItem.data.
    }
  ],
  "rawInfo": {
    "meta": {
      ## Truncated!
    }
  },
  "results": [
    ResultItem {
      "data": {
        "title": {
          "raw": "Everglades"
        },
        "description": {
          "raw": "The Everglades are the largest tropical wilderness"
        },
        "id": {
          "raw": "park_everglades"
        },
        "_meta": {
          "score": 1.0028129
        }
      }
    },
    ResultItem {
      "data": {
        "title": {
          "raw": "Voyageurs"
        },
        "description": {
          "raw": "This park protecting four lakes near the Canada–US"
        },
        "id": {
          "raw": "park_voyageurs"
        },
        "_meta": {
          "score": 0.0062864386
        }
      }
    },
    ResultItem {
      "data": {
        "title": {
          "raw": "Wrangell–St. Elias"
        },
        "description": {
          "raw": "An over 8 million acres (32,375 km2) plot of"
        },
        "id": {
          "raw": "park_wrangell–st.-elias"
        },
        "_meta": {
          "score": 0.00437395
        }
      }
    }
  ],
  "info": {
    "meta": {
      ## Truncated!
    }
  }
}

Returning Result Fields as Snippets

Requests a snippet of a text field.

The result will include the matched query value wrapped within <em></em> tags and highlighted, if a match exists.

If requesting a snippet on a non-text field or if there is no match for your query, the snippet field will be null.

Snippets on an array value will return the first match or null. There is no fallback support.

On synonyms: If a search finds a synonym for a query, the synonym will not be highlighted. For example, if "path" and "trail" are synonyms and a query is done for "path", the term "trail" will not be highlighted.

size
optional
Character length of the snippet returned. Must be at least 20; defaults to 100.
fallback
optional
If true, return the raw text field if no snippet is found. If false, only use snippets.
Example - Specifying result_fields snippets for title, description, and states.
curl -X GET 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-soaewu2ye6uc45dr8mcd54v8' \
-d '{
  "query": "everglade",
  "result_fields": {
    "title": {
      "snippet": {
        "size": 20,
        "fallback": true
      }
    },
    "description": {
      "raw": {
        "size": 200
      },
      "snippet": {
        "size": 100
      }
    },
    "states": {
      "raw" : {},
      "snippet": {
        "size": 20,
        "fallback": true
      }
    }
  }
}'
Example Response
{
  "meta": {
    "warnings": [],
    "page": {
      ## Truncated!
    },
    "request_id": "2fd235c15c28a697d70f9a5dc0bdb0fb"
  },
  "results": [
    {
      "title": {
        "snippet": "<em>Everglades</em>"
      },
      "states": {
        "raw": [
          "Florida"
        ],
        "snippet": "Florida"
      },
      "description": {
        "raw": "The Everglades are the largest tropical wilderness in the United States. This mangrove and tropical rainforest ecosystem and marine estuary is home to 36 protected species, including the Florida",
        "snippet": "The <em>Everglades</em> are the largest tropical wilderness in the United States. This mangrove and tropical"
      },
      "id": {
        "raw": "park_everglades"
      },
      "_meta": {
        "score": 1.0028129
      }
    },
    {
      "title": {
        "snippet": "Voyageurs"
      },
      "states": {
        "raw": [
          "Minnesota"
        ],
        "snippet": "Minnesota"
      },
      "description": {
        "raw": "This park protecting four lakes near the Canada–US border is a site for canoeing, kayaking, and fishing. The park also preserves a history populated by Ojibwe Native Americans, French fur traders",
        "snippet": null
      },
      "id": {
        "raw": "park_voyageurs"
      },
      "_meta": {
        "score": 0.0062864386
      }
    },
    {
      "title": {
        "snippet": "Wrangell–St. Elias"
      },
      "states": {
        "raw": [
          "Alaska"
        ],
        "snippet": "Alaska"
      },
      "description": {
        "raw": "An over 8 million acres (32,375 km2) plot of mountainous country—the largest National Park in the system—protects the convergence of the Alaska, Chugach, and Wrangell-Saint Elias Ranges, which include",
        "snippet": null
      },
      "id": {
        "raw": "park_wrangell–st.-elias"
      },
      "_meta": {
        "score": 0.00437395
      }
    }
  ]
}

Example - Specifying result_fields snippets for title, description, and states.
import com.swiftype.appsearch.Client;
import com.swiftype.appsearch.ClientException;
import java.util.*;

Client client = new Client("host-2376rb", "search-soaewu2ye6uc45dr8mcd54v8");

String engineName = "national-parks-demo"; String query = "everglade";

Map<String, Object> titleSnippet = new HashMap<>(); titleSnippet.put("size", 20); titleSnippet.put("fallback", true); Map<String, Object> title = new HashMap<>(); title.put("snippet", titleSnippet);

Map<String, Object> statesSnippet = new HashMap<>(); statesSnippet.put("size", 20); Map<String, Object> states = new HashMap<>(); states.put("snippet", statesSnippet); states.put("raw", Collections.emptyMap());

Map<String, Integer> descriptionRaw = new HashMap<>(); descriptionRaw.put("size", 200); Map<String, Integer> descriptionSnippet = new HashMap<>(); descriptionSnippet.put("size", 100); Map<String, Object> description = new HashMap<>(); description.put("raw", descriptionRaw); description.put("snippet", descriptionSnippet);

Map<String, Object> resultFields = new HashMap<>(); resultFields.put("title", title); resultFields.put("states", states); resultFields.put("description", description);

Map<String, Object> options = new HashMap<>(); options.put("result_fields", resultFields);

try { Map<String, Object> response = client.search(engineName, query, options); System.out.println(response); } catch (ClientException e) { System.out.println(e); }

Example Response
Map<String, Object>: {
  "meta": {
    "warnings": [],
    "page": {
      ## Truncated!
    },
    "request_id": "2fd235c15c28a697d70f9a5dc0bdb0fb"
  },
  "results": [
    {
      "title": {
        "snippet": "<em>Everglades</em>"
      },
      "states": {
        "raw": [
          "Florida"
        ],
        "snippet": "Florida"
      },
      "description": {
        "raw": "The Everglades are the largest tropical wilderness in the United States. This mangrove and tropical rainforest ecosystem and marine estuary is home to 36 protected species, including the Florida",
        "snippet": "The <em>Everglades</em> are the largest tropical wilderness in the United States. This mangrove and tropical"
      },
      "id": {
        "raw": "park_everglades"
      },
      "_meta": {
        "score": 1.0028129
      }
    },
    {
      "title": {
        "snippet": "Voyageurs"
      },
      "states": {
        "raw": [
          "Minnesota"
        ],
        "snippet": "Minnesota"
      },
      "description": {
        "raw": "This park protecting four lakes near the Canada–US border is a site for canoeing, kayaking, and fishing. The park also preserves a history populated by Ojibwe Native Americans, French fur traders",
        "snippet": null
      },
      "id": {
        "raw": "park_voyageurs"
      },
      "_meta": {
        "score": 0.0062864386
      }
    },
    {
      "title": {
        "snippet": "Wrangell–St. Elias"
      },
      "states": {
        "raw": [
          "Alaska"
        ],
        "snippet": "Alaska"
      },
      "description": {
        "raw": "An over 8 million acres (32,375 km2) plot of mountainous country—the largest National Park in the system—protects the convergence of the Alaska, Chugach, and Wrangell-Saint Elias Ranges, which include",
        "snippet": null
      },
      "id": {
        "raw": "park_wrangell–st.-elias"
      },
      "_meta": {
        "score": 0.00437395
      }
    }
  ]
}

Example - Specifying result_fields snippets for title, description, and states.
const SwiftypeAppSearchClient = require('swiftype-app-search-node')

const client = new SwiftypeAppSearchClient('host-2376rb', 'search-soaewu2ye6uc45dr8mcd54v8')

const engineName = 'national-parks-demo' const query = 'red'

const options = { result_fields: { title: { snippet: { size: 20, fallback: true } }, states: { raw: {}, snippet: { size: 20, fallback: true } }, description: { raw: { size: 200 }, snippet: { size: 100 } } } }

client .search(engineName, query, options) .then(response => console.log(response)) .catch(error => console.log(error))

Example Response
{
  "meta": {
    "warnings": [],
    "page": {
      ## Truncated!
    },
    "request_id": "2fd235c15c28a697d70f9a5dc0bdb0fb"
  },
  "results": [
    {
      "title": {
        "snippet": "<em>Everglades</em>"
      },
      "states": {
        "raw": [
          "Florida"
        ],
        "snippet": "Florida"
      },
      "description": {
        "raw": "The Everglades are the largest tropical wilderness in the United States. This mangrove and tropical rainforest ecosystem and marine estuary is home to 36 protected species, including the Florida",
        "snippet": "The <em>Everglades</em> are the largest tropical wilderness in the United States. This mangrove and tropical"
      },
      "id": {
        "raw": "park_everglades"
      },
      "_meta": {
        "score": 1.0028129
      }
    },
    {
      "title": {
        "snippet": "Voyageurs"
      },
      "states": {
        "raw": [
          "Minnesota"
        ],
        "snippet": "Minnesota"
      },
      "description": {
        "raw": "This park protecting four lakes near the Canada–US border is a site for canoeing, kayaking, and fishing. The park also preserves a history populated by Ojibwe Native Americans, French fur traders",
        "snippet": null
      },
      "id": {
        "raw": "park_voyageurs"
      },
      "_meta": {
        "score": 0.0062864386
      }
    },
    {
      "title": {
        "snippet": "Wrangell–St. Elias"
      },
      "states": {
        "raw": [
          "Alaska"
        ],
        "snippet": "Alaska"
      },
      "description": {
        "raw": "An over 8 million acres (32,375 km2) plot of mountainous country—the largest National Park in the system—protects the convergence of the Alaska, Chugach, and Wrangell-Saint Elias Ranges, which include",
        "snippet": null
      },
      "id": {
        "raw": "park_wrangell–st.-elias"
      },
      "_meta": {
        "score": 0.00437395
      }
    }
  ]
}

Example - Specifying result_fields snippets for title, description, and states.
require 'swiftype-app-search'

host_identifier = 'host-2376rb' api_key = 'search-soaewu2ye6uc45dr8mcd54v8' client = SwiftypeAppSearch::Client.new(host_identifier: host_identifier, api_key: api_key)

engine_name = 'national-parks-demo' query = 'red'

options = { result_fields: { title: { snippet: { size: 20, fallback: true } }, description: { raw: { size: 200 }, snippet: { size: 100 } }, states: { raw: {}, snippet: { size: 20, fallback: true } } } }

begin puts client.search(engine_name, query, options) rescue SwiftypeAppSearch::ClientException => e puts e end

Example Response
{
  "meta" => {
    "warnings" => [], "page" => {
      "current" => 1, "total_pages" => 2, "total_results" => 18, "size" => 10
    }, "request_id" => "8c817238da26b4ec63b78cf275e9e049"
  }, "results" => [{
    "title" => {
      "snippet" => "Petrified Forest"
    },
    "states" => {
      "raw" => ["Arizona"], "snippet" => "Arizona"
    },
    "description" => {
      "raw" => "This portion of the Chinle Formation has a large concentration of 225-million-year-old petrified wood. The surrounding Painted Desert features eroded cliffs of red-hued volcanic rock called bentonite.", "snippet" => " wood. The surrounding Painted Desert features eroded cliffs of <em>red</em>-hued volcanic rock called bentonite"
    },
    "id" => {
      "raw" => "park_petrified-forest"
    },
    "_meta" => {
      "score" => 8.545094
    }
  }, {
    "title" => {
      "snippet" => "<em>Redwood</em>"
    },
    "states" => {
      "raw" => ["California"], "snippet" => "California"
    },
    "description" => {
      "raw" => "This park and the co-managed state parks protect almost half of all remaining coastal redwoods, the tallest trees on earth. There are three large river systems in this very seismically active area,", "snippet" => "This park and the co-managed state parks protect almost half of all remaining coastal <em>redwoods</em>, the"
    },
    "id" => {
      "raw" => "park_redwood"
    },
    "_meta" => {
      "score" => 0.33619994
    }
  }, {
    "title" => {
      "snippet" => "Lake Clark"
    },
    "states" => {
      "raw" => ["Alaska"], "snippet" => "Alaska"
    },
    "description" => {
      "raw" => "The region around Lake Clark features four active volcanoes, including Mount Redoubt, as well as an abundance of rivers, glaciers, and waterfalls. Temperate rainforests, a tundra plateau, and three", "snippet" => "The region around Lake Clark features four active volcanoes, including Mount <em>Redoubt</em>, as well as an"
    },
    "id" => {
      "raw" => "park_lake-clark"
    },
    "_meta" => {
      "score" => 0.017497728
    }
  }, {
    "title" => {
      "snippet" => "Kings Canyon"
    },
    "states" => {
      "raw" => ["California"], "snippet" => "California"
    },
    "description" => {
      "raw" => "Home to several giant sequoia groves and the General Grant Tree, the world's second largest measured tree, this park also features part of the Kings River, sculptor of the dramatic granite canyon that", "snippet" => nil
    },
    "id" => {
      "raw" => "park_kings-canyon"
    },
    "_meta" => {
      "score" => 0.0011171611
    }
  }, {
    "title" => {
      "snippet" => "Haleakala"
    },
    "states" => {
      "raw" => ["Hawaii"], "snippet" => "Hawaii"
    },
    "description" => {
      "raw" => "The Haleakala volcano on Maui features a very large crater with numerous cinder cones, Hosmer's Grove of alien trees, the Kipahulu section's scenic pools of freshwater fish, and the native Hawaiian", "snippet" => nil
    },
    "id" => {
      "raw" => "park_haleakala"
    },
    "_meta" => {
      "score" => 0.0011171611
    }
  }, {
    "title" => {
      "snippet" => "Grand Teton"
    },
    "states" => {
      "raw" => ["Wyoming"], "snippet" => "Wyoming"
    },
    "description" => {
      "raw" => "Grand Teton is the tallest mountain in the Teton Range. The park's historic Jackson Hole and reflective piedmont lakes teem with endemic wildlife, with a backdrop of craggy mountains that rise", "snippet" => nil
    },
    "id" => {
      "raw" => "park_grand-teton"
    },
    "_meta" => {
      "score" => 0.0011171611
    }
  }, {
    "title" => {
      "snippet" => "Grand Canyon"
    },
    "states" => {
      "raw" => ["Arizona"], "snippet" => "Arizona"
    },
    "description" => {
      "raw" => "The Grand Canyon, carved by the mighty Colorado River, is 277 miles (446 km) long, up to 1 mile (1.6 km) deep, and up to 15 miles (24 km) wide. Millions of years of erosion have exposed the", "snippet" => nil
    },
    "id" => {
      "raw" => "park_grand-canyon"
    },
    "_meta" => {
      "score" => 0.0011171611
    }
  }, {
    "title" => {
      "snippet" => "Denali"
    },
    "states" => {
      "raw" => ["Alaska"], "snippet" => "Alaska"
    },
    "description" => {
      "raw" => "Centered on Denali, the tallest mountain in North America, Denali is serviced by a single road leading to Wonder Lake. Denali and other peaks of the Alaska Range are covered with long glaciers and", "snippet" => nil
    },
    "id" => {
      "raw" => "park_denali"
    },
    "_meta" => {
      "score" => 0.0011171611
    }
  }, {
    "title" => {
      "snippet" => "Bryce Canyon"
    },
    "states" => {
      "raw" => ["Utah"], "snippet" => "Utah"
    },
    "description" => {
      "raw" => "Bryce Canyon is a geological amphitheater on the Paunsaugunt Plateau with hundreds of tall, multicolored sandstone hoodoos formed by erosion. The region was originally settled by Native Americans and", "snippet" => nil
    },
    "id" => {
      "raw" => "park_bryce-canyon"
    },
    "_meta" => {
      "score" => 0.0011171611
    }
  }, {
    "title" => {
      "snippet" => "Shenandoah"
    },
    "states" => {
      "raw" => ["Virginia"], "snippet" => "Virginia"
    },
    "description" => {
      "raw" => "Shenandoah's Blue Ridge Mountains are covered by hardwood forests that teem with a wide variety of wildlife. The Skyline Drive and Appalachian Trail run the entire length of this narrow park, along", "snippet" => nil
    },
    "id" => {
      "raw" => "park_shenandoah"
    },
    "_meta" => {
      "score" => 0.0008564528
    }
  }]
}

Example - Specifying result_fields snippets for title, description, and states.
from swiftype_app_search import Client
from swiftype_app_search.exceptions import SwiftypeAppSearchError

host_identifier = 'host-2376rb' api_key = 'search-soaewu2ye6uc45dr8mcd54v8' client = Client(host_identifier, api_key)

engine_name = 'national-parks-demo' query = 'everglade'

options = { 'result_fields': { 'title': { 'snippet': { 'size': 20, 'fallback': True } }, 'states': { 'raw': {}, 'snippet': { 'size': 20, 'fallback': true } }, 'description': { 'raw': { 'size': 200 }, 'snippet': { 'size': 100 } } } }

try: print(client.search(engine_name, query, options)) except SwiftypeAppSearchError as e: print(e)

Example Response
{
    'meta': {
        ## Truncated!
    },
    'results': [
        {
            'states': {
                'raw': [
                  'Florida'
                ]
            },
            'description': {
                'raw': 'The Everglades are the largest tropical wilderness in the United States. This mangrove and tropical rainforest ecosystem and marine estuary is home to 36 protected species, including the Florida',
                'snippet': 'The <em>Everglades</em> are the largest tropical wilderness in the United States. This mangrove and tropical.'
            },
            'id': {
                'raw': 'park_everglades'
            },
            'title': {
                'snippet': '<em>Everglades</em>'
            },
            '_meta': {
                'score': 1.0028129
            }
        },
        {
            'states': {
                'raw': [
                  'Minnesota'
                ]
            },
            'description': {
                'raw': 'This park protecting four lakes near the Canada–US border is a site for canoeing, kayaking, and fishing. The park also preserves a history populated by Ojibwe Native Americans, French fur traders'
            },
            'id': {
                'raw': 'park_voyageurs'
            },
            'title': {
                'snippet': 'Voyageurs'
            },
            '_meta': {
                'score': 0.0062864386
            }
        },
        {
            'states': {
                'raw': [
                  'Alaska'
                ]
            },
            'description': {
                'raw': 'An over 8 million acres (32,375 km2) plot of mountainous country—the largest National Park in the system—protects the convergence of the Alaska, Chugach, and Wrangell-Saint Elias Ranges, which include'
            },
            'id': {
                'raw': 'park_wrangell–st.-elias'
            },
            'title': {
                'snippet': 'Wrangell–St. Elias'
            },
            '_meta': {
                'score': 0.00437395
            }
        }
    ]
}

Example - Specifying result_fields snippets for title, description, and states.
const client = SwiftypeAppSearch.createClient({
  hostIdentifier: 'host-2376rb',
  searchKey: 'search-soaewu2ye6uc45dr8mcd54v8',
  engineName: 'national-parks-demo'
})

const query = 'everglade'

const options = { result_fields: { title: { snippet: { size: 20, fallback: true } }, states: { raw: {}, snippet: { size: 20 } }, description: { raw: { size: 200 }, snippet: { size: 100 } } } }

client .search(query, options) .then(function(response){ console.log(response) }) .catch(function(error){ console.log(error) })

Example Response
ResultList {
  "rawResults": [
    {
      ## Truncated! Same as ResultItem.data.
    },
    {
      ## Truncated! Same as ResultItem.data.
    }
  ],
  "rawInfo": {
    "meta": {
      ## Truncated!
    }
  },
  "results": [
    ResultItem {
      "data": {
        "title": {
          "snippet": "<em>Everglades</em>"
        },
        "states": {
          "raw": [
            "Florida"
          ],
          "snippet": "Florida"
        },
        "description": {
          "raw": "The Everglades are the largest tropical wilderness in the United States. This mangrove and tropical rainforest ecosystem and marine estuary is home to 36 protected species, including the Florida",
          "snippet": "The <em>Everglades</em> are the largest tropical wilderness in the United States. This mangrove and tropical"
        },
        "id": {
          "raw": "park_everglades"
        },
        "_meta": {
          "score": 1.0028129
        }
      }
    },
    ResultItem {
      "data": {
        "title": {
          "snippet": "Voyageurs"
        },
        "states": {
          "raw": [
            "Minnesota"
          ],
          "snippet": "Minnesota"
        },
        "description": {
          "raw": "This park protecting four lakes near the Canada–US border is a site for canoeing, kayaking, and fishing. The park also preserves a history populated by Ojibwe Native Americans, French fur traders",
          "snippet": null
        },
        "id": {
          "raw": "park_voyageurs"
        },
        "_meta": {
          "score": 0.0062864386
        }
      }
    },
    ResultItem {
      "data": {
        "title": {
          "snippet": "Wrangell–St. Elias"
        },
        "states": {
          "raw": [
            "Alaska"
          ],
          "snippet": "Alaska"
        },
        "description": {
          "raw": "An over 8 million acres (32,375 km2) plot of mountainous country—the largest National Park in the system—protects the convergence of the Alaska, Chugach, and Wrangell-Saint Elias Ranges, which include",
          "snippet": null
        },
        "id": {
          "raw": "park_wrangell–st.-elias"
        },
        "_meta": {
          "score": 0.00437395
        }
      }
    }
  ],
  "info": {
    "meta": {
      ## Truncated!
    }
  }
}

Errors

result_fieldsIf a result field requested does not exist in the current schema.
If a request field JSON object is malformed. It must be an empty JSON object or have keys of raw and/or snippet and a value of a JSON object optionally containing keys of size and fallback (if requesting a snippet).
If the requested raw size is less than 15.
If a size is requested for a non text field.
If the requested snippet size is not greater or equal to 20 and less than 1000.
If the fallback parameter for a snippet is not a boolean.

Stuck? Looking for help? Contact support or check out the App Search forum!