An API client for Swiftype App Search
Project description
Note: Swiftype App Search is currently in beta
About
A Python client for interacting with Swiftype App Search API.
For more information, go to our official documentation page: https://swiftype.com/documentation/app-search/
Installation
Swiftype App Search Client can be installed with pip:
$ python -m pip install swiftype_app_search
You can also download the project source and run:
$ python setup.py install
Dependencies
Swiftype App Search supports Python 2.7 and Python 3.3+. It depends on requests.
Usage
Instantiating a client
>>> from swiftype_app_search import Client
>>> account_host_key = 'host-c5s2mj'
>>> api_key = 'api-mu75psc5egt9ppzuycnc2mc3'
>>> client = Client(account_host_key, api_key)
Index documents
>>> engine_name = 'favorite-videos'
>>> documents = [
{
'id': 'INscMGmhmX4',
'url': 'https://www.youtube.com/watch?v=INscMGmhmX4',
'title': 'The Original Grumpy Cat',
'body': 'A wonderful video of a magnificent cat.'
},
{
'id': 'JNDFojsd02',
'url': 'https://www.youtube.com/watch?v=dQw4w9WgXcQ',
'title': 'Another Grumpy Cat',
'body': 'A great video of another cool cat.'
}
]
>>> client.index_documents(engine_name, documents)
[{'id': 'INscMGmhmX4', 'errors': []}, {'id': 'JNDFojsd02', 'errors': []}]
Get Documents
>>> engine_name = 'favorite-videos'
>>> client.get_documents(engine_name, ['INscMGmhmX4'])
[{'id': 'INscMGmhmX4','url': 'https://www.youtube.com/watch?v=INscMGmhmX4','title': 'The Original Grumpy Cat','body': 'A wonderful video of a magnificent cat.'}]
Destroy Documents
>>> engine_name = 'favorite-videos'
>>> client.destroy_documents(engine_name, ['INscMGmhmX4'])
[{'id': 'INscMGmhmX4','result': True}]
List Engines
>>> client.list_engines()
[{'name': 'favorite-videos'}, {'name': 'another-engine'}]
Get an Engine
>>> client.get_engine('favorite-videos')
{'name': 'favorite-videos'}
Create an Engine
>>> client.create_engine('favorite-videos')
{'name': 'favorite-videos'}
Destroy an Engine
>>> client.destroy_engine('favorite-videos')
{'deleted': True}
Search
>>> client.search('favorite-videos', 'grumpy cat', {})
{'meta': {'page': {'current': 1, 'total_pages': 1, 'total_results': 2, 'size': 10}, ...}, 'results': [...]}
Create a Signed Search Key
Creating a search key that will only search over the body field.
>>> api_key = 'api-mu75psc5egt9ppzuycnc2mc3'
>>> api_key_id = '42'
>>> signed_search_key = Client.create_signed_search_key(api_key, api_key_id, {'search_fields': { 'body': {}}})
>>> client = Client(account_host_key, signed_search_key)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for swiftype_app_search-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f8244a51a2145b21e6b75b0c2e484e25d76360e9931c8c0dc93ff901b649e91a |
|
MD5 | 6f8ada8792f659e0fc87fc7379ba66ac |
|
BLAKE2b-256 | d9225a22b7f37f532ebb3a685df90c2514fcde19599002e8a9df03ea1788054c |
Close
Hashes for swiftype_app_search-0.1.0-py2.7.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca362abd1bb47a9c31a57ab6f7609164dc347ac78a778a1fc2f78b368eb68dc8 |
|
MD5 | f3f0b90142bc0eeba2ebbc29d330ef39 |
|
BLAKE2b-256 | af75a99c9850814c5b68df150022ddc9bd12dce571a5f8091690a79350d99796 |