Azimfamily Azimfamily: Getting started with API Engine

.

Getting started with API Engine

Add Documents
After you've designed your schema, get started by adding Documents.
To indexDocuments use the examples below as a starting point. We only use the stringenumfield types below, but the API supports many additional types (see above).
To add Documents of the azimfamilyDocumentType, use the following commands:
curl -XPOST 'https://api.swiftype.com/api/v1/engines/azimfamily/document_types/azimfamily/documents.json' \
-H 'Content-Type: application/json' \
-d '{
  "auth_token":"j8YsHUH8S7qnMLFLG8-B",
  "document": {
    "external_id": "1",
"fields"
      {"name": "title", "value": "The Great Gatsby", "type": "string"},
      {"name": "author", "value": "F. Scott Fitzgerald", "type": "string"},
      {"name": "genre", "value": "fiction", "type": "enum"}
  }
}'

curl -XPOST 'https://api.swiftype.com/api/v1/engines/azimfamily/document_types/azimfamily/documents.json' \
-H 'Content-Type: application/json' \
-d '{
  "auth_token":"j8YsHUH8S7qnMLFLG8-B",
  "document": {
    "external_id": "2",
    "fields": [
      {"name": "title", "value": "The Brothers Karamazov", "type": "string"},
      {"name": "author", "value": "Fyodor Dostoevsky", "type": "string"},
      {"name": "genre", "value": "fiction", "type": "enum"}
    ]
  }
}'

3. Search Documents in 'azimfamily'
Now you're ready to issue queries to your search engine. By default, search queries will match any fields that are of the type string or text. You may search each DocumentType individually:
To search Documents of the azimfamily DocumentType, use the following command:
curl -XGET 'https://api.swiftype.com/api/v1/engines/azimfamily/document_types/azimfamily/search.json' \
-H 'Content-Type: application/json' \
-d '{
  "auth_token":"j8YsHUH8S7qnMLFLG8-B",
  "q":"brothers"
}'
Or you may search over all DocumentTypes on 'azimfamily' at once:
curl -XGET 'https://api.swiftype.com/api/v1/engines/azimfamily/search.json' \
-H 'Content-Type: application/json' \
-d '{
  "auth_token":"j8YsHUH8S7qnMLFLG8-B",
  "q":"the"
}'

4. Autocomplete searches
Finally, as with full-text searches, you may perform autocomplete-style (prefix match) searches as well:

curl -XGET 'https://api.swiftype.com/api/v1/engines/azimfamily/suggest.json' \
-H 'Content-Type: application/json' \
-d '{
  "auth_token":"j8YsHUH8S7qnMLFLG8-B",
  "q":"fitz"
}'

Tiada ulasan: