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
-
engineKey
Key to the engine that queries will run against
property -
delegate
The delegate which will provide parameter data and receive messages related to the query
property -
+ clearAPICache
Clear 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.
-
– cancelQuery
Cancel 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
STSearchResultObjects
postClickAnalyticsWithDocumentId method.
Properties
Instance Methods
cancelQuery
Cancel any pending requests with the search server
- (void)cancelQuery
Discussion
Cancel any pending requests with the search server
Declared In
STAPIClient.h
initWithApiKey:
Initializes a new STAPIClient
- (id)initWithApiKey:(NSString *)engineKey
Parameters
- engineKey
The key of the engine that queries will be run against
Discussion
Initializes a new STAPIClient
Declared In
STAPIClient.h
postClickAnalyticsForQuery: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 *)documentId
Parameters
- 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.h
searchQuery:
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 *)query
Parameters
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.h
searchQuery: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)perPage
Discussion
Starts a new search query with the server for a specific page and certain number of results.
Declared In
STAPIClient.h
suggestQuery:
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 *)query
Parameters
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