dev-master
9999999-dev https://github.com/Nevon/swiftype-phpA PHP client for Swiftype, a search and autocomplete API for developers.
MIT
The Requires
- php ^5.3
Wallogit.com
2017 © Pedro Peláez
A PHP client for Swiftype, a search and autocomplete API for developers.
A PHP client for Elastic Site Search, a search and autocomplete API for developers., (*1)
⚠️ This integration is deprecated and you should use the official client instead., (*2)
require 'swiftype.php';
$client = new \Swiftype\SwiftypeClient('your@email.com', 'password', 'api_key');
print_r($client->create_engine('library'));
print_r($client->create_document_type('library', 'books'));
print_r($client->create_document('library', 'books', array(
'external_id' => '1',
'fields' => array(
array(
'name' => 'title',
'value' => 'The Art of Community',
'type' => 'string'
),
array(
'name' => 'author',
'value' => 'Jono Bacon',
'type' => 'enum'
)
)
)));
print_r($client->documents('library', 'books'));
The library should conform to the documentation found here., (*3)
The constructor for the SwiftypeClient object. Set your authentication information here. You can supply either an API key or a username (email) and password combination., (*4)
$client = new \Swiftype\SwiftypeClient('your@email.com', 'password', 'api_key');, (*5)
Returns all your engines, (*6)
$client->engines();, (*7)
Returns a specific engine., (*8)
$client->engine('library');, (*9)
Creates a new engine, (*10)
$client->create_engine('library');, (*11)
Destroys an engine, (*12)
$client->destroy_engine('library');, (*13)
Returns a list of all the document types for a certain engine, (*14)
$client->document_types('library');, (*15)
Fetches a specific document_type., (*16)
$client->document_type('library', 'books');, (*17)
Creates a document type for a specific engine., (*18)
$client->create_document_type('library', 'books');, (*19)
Destroys a document type., (*20)
$client->destroy_document_type('library', 'books');, (*21)
Returns all documents for a certain engine and document type., (*22)
$client->documents('library', 'books');, (*23)
Returns a specific document., (*24)
$client->document('library', 'books', '1');, (*25)
Creates a document. A document is an associative array containing an external_id and a number of fields. See [this](http://swiftype.com/documentation/overview# field_types) for more information on fields and types., (*26)
$client->create_document('library', 'books', array(
'external_id' => '1',
'fields' => array(
array(
'name' => 'title',
'value' => 'The Art of Community',
'type' => 'string'
),
array(
'name' => 'author',
'value' => 'Bono Jacon',
'type' => 'enum'
)
)
));
Same as create_document, except it updates an existing document if there is one., (*27)
$client->create_or_update_document('library', 'books', array(
'external_id' => '1',
'fields' => array(
array(
'name' => 'author',
'value' => 'Jono Blargon',
'type' => 'enum'
)
)
));
Updates a single document with the specified document_id., (*28)
$client->update_document('library', 'books', '1', array('author' => 'Jorbo Bacon'));
Batch operation for updating documents. documents is simply an array containing arrays of the same type that we supplied to the create_documentmethod., (*29)
$client->update_documents('library', 'books', array(
array(
'external_id' => '1',
'fields' => array(
'name' => 'author',
'value' => 'Jono Bacon',
)
)
));
Destroys a document., (*30)
$client->destroy_document('library', 'books', '1');, (*31)
Destroy documents in bulk. document_ids is a simple array containing the external_ids of the documents you wish to destroy., (*32)
$client->destroy_documents('library', 'books', array('1', '2'));, (*33)
If you do not supply a document_type_id, search searches through the specified engine to find a document type that matches the query. If a document_type_id is supplied, then search searches through that particular document type in that engine for a document that matches the query., (*34)
To see what options are available, see the documentation., (*35)
$client->search('library', 'books', 'community', array(
'per_page' => 5
));
Used for autocompletion. See the documentation for more information., (*36)
$client->suggest('library', 'Bacon', array(
'search_fields' => 'author'
));
A PHP client for Swiftype, a search and autocomplete API for developers.
MIT