Scout Client¶

Scout comes with a simple Python client. This document describes the client API.

The Scout class provides a simple, Pythonic API for interacting with and querying a Scout server.

Example of initializing the client:

>>> from scout_client import Scout >>> scout = Scout('https://search.my-site.com/', key='secret!') 
get_indexes ( ** kwargs ) ¶

Return the list of indexes available on the server.

See Index list: “/” for more information.

Create a new index with the given name. If an index with that name already exists, you will receive a 400 response.

See the POST section of Index list: “/” for more information.

rename_index ( old_name , new_name ) ¶

Rename an existing index.

Delete an existing index. Any documents associated with the index will not be deleted.

Return the details about the particular index, along with a paginated list of all documents stored in the given index.

The following optional parameters are supported:

The Filtering on Metadata section describes how to use key/value pairs t construct filters on the document’s metadata.

create_document ( content , indexes [ , identifier=None [ , attachments=None [ , **metadata ] ] ] ) ¶

Store a document in the specified index(es).

Update one or more attributes of a document that’s stored in the database.

If you specify metadata when updating a document, existing metadata will be replaced by the new metadata. To simply clear out the metadata for an existing document, pass an empty dict .

delete_document ( document_id ) ¶

Remove a document from the database, as well as all indexes.

document_id (int) – The integer document ID.

Retrieve content for the given document.

document_id (int) – The integer document ID.

Retrieve a paginated list of all documents in the database, regardless of index. This method can also be used to perform full-text search queries across the entire database of documents, or a subset of indexes.

The following optional parameters are supported:

The Filtering on Metadata section describes how to use key/value pairs t construct filters on the document’s metadata.

Upload the attachments and associate them with the given document.

Detach the specified file from the document.

Replace the contents of the current attachment with the contents of file_object .

get_attachments ( document_id , ** kwargs ) ¶

Retrieve a paginated list of attachments associated with the given document.

The following optional parameters are supported:

get_attachment ( document_id , filename ) ¶

Retrieve data about the given attachment.

download_attachment ( document_id , filename ) ¶

Download the specified attachment.