STAPIClient Class Reference
| Inherits from | NSObject |
| Conforms to | NSURLConnectionDataDelegate NSURLConnectionDelegate |
| Declared in | STAPIClient.h STAPIClient.m |
Overview
The STAPIClient is used to communicate with the Swiftype search servers. In order to work correctly
it must have a delegate that defines the search parameters as well as an engine key. Details on the search
parameters can be found here: http://swiftype.com/documentation/searching. An search engine’s key can be
found within the account’s dashboard: http://swiftype.com/home.
The STAPIClient client is meant to run exactly 1 query at a time. If a query is pending (waiting for
the server to respond) when another query is issued then that first query is canceled. A query will start
and then finish or be canceled or fail. A query cannot for example fail and be canceled for the same request.
The client offers two types of queries: search and suggest. More detailed information on suggest queries
can be found here http://swiftype.com/documentation/autocomplete.
It is not common to use STAPIClient directly. Instead it is recommended to use STSearchResultsObject or
one of its subclasses.
Tasks
-
engineKeyKey to the engine that queries will run against
property -
delegateThe delegate which will provide parameter data and receive messages related to the query
property -
+ clearAPICacheClear the cache that is used by all instance of STAPIClient
-
– initWithApiKey:Initializes a new
STAPIClient -
– searchQuery:Starts a new search query with the server. By default the query will request only the first 20 results for each document type.
-
– searchQuery:page:perPage:Starts a new search query with the server for a specific page and certain number of results.
-
– suggestQuery:Starts a new suggest query with the server. By default the query will request only the first 20 results for each document type.
-
– cancelQueryCancel any pending requests with the search server
-
– postClickAnalyticsForQuery:withType:documentId:Used to log user interaction with the search results. This is typically called by the
STSearchResultObjectspostClickAnalyticsWithDocumentId method.
Properties
Instance Methods
cancelQuery
Cancel any pending requests with the search server
- (void)cancelQueryDiscussion
Cancel any pending requests with the search server
Declared In
STAPIClient.hinitWithApiKey:
Initializes a new STAPIClient
- (id)initWithApiKey:(NSString *)engineKeyParameters
- engineKey
The key of the engine that queries will be run against
Discussion
Initializes a new STAPIClient
Declared In
STAPIClient.hpostClickAnalyticsForQuery:withType:documentId:
Used to log user interaction with the search results. This is typically called by the STSearchResultObjects
postClickAnalyticsWithDocumentId method.
- (void)postClickAnalyticsForQuery:(NSString *)query withType:(STSearchType)type documentId:(NSString *)documentIdParameters
- query
The query the that was run against the server that found a particular result
- type
The search type. Whether it was a suggest or a search query.
- documentId
The id of the document that was selected.
Discussion
Used to log user interaction with the search results. This is typically called by the STSearchResultObjects
postClickAnalyticsWithDocumentId method.
It is the responsibility of custom UI to call this once a user has selected a search result.
Declared In
STAPIClient.hsearchQuery:
Starts a new search query with the server. By default the query will request only the first 20 results for each document type.
- (void)searchQuery:(NSString *)queryParameters
Discussion
Starts a new search query with the server. By default the query will request only the first 20 results for each document type.
Declared In
STAPIClient.hsearchQuery:page:perPage:
Starts a new search query with the server for a specific page and certain number of results.
- (void)searchQuery:(NSString *)query page:(NSUInteger)page perPage:(NSUInteger)perPageDiscussion
Starts a new search query with the server for a specific page and certain number of results.
Declared In
STAPIClient.hsuggestQuery:
Starts a new suggest query with the server. By default the query will request only the first 20 results for each document type.
- (void)suggestQuery:(NSString *)queryParameters
Discussion
Starts a new suggest query with the server. By default the query will request only the first 20 results for each document type.
Declared In
STAPIClient.h