2017 © Pedro Peláez
 

library swiftype

A PHP client for Swiftype, a search and autocomplete API for developers.

image

nevon/swiftype

A PHP client for Swiftype, a search and autocomplete API for developers.

  • Thursday, August 10, 2017
  • by Nevon
  • Repository
  • 4 Watchers
  • 23 Stars
  • 6 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 20 Forks
  • 2 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

swiftype-php

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)

Example usage

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'));

Documentation

The library should conform to the documentation found here., (*3)

__construct([username String], [password String], [api_key String], [host String], [api_base_path String])

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)

engines()

Returns all your engines, (*6)

$client->engines();, (*7)

engine(engine_id String)

Returns a specific engine., (*8)

$client->engine('library');, (*9)

create_engine(engine_id String)

Creates a new engine, (*10)

$client->create_engine('library');, (*11)

destroy_engine(engine_id String)

Destroys an engine, (*12)

$client->destroy_engine('library');, (*13)

document_types(engine_id String)

Returns a list of all the document types for a certain engine, (*14)

$client->document_types('library');, (*15)

document_type(engine_id String, document_type_id String)

Fetches a specific document_type., (*16)

$client->document_type('library', 'books');, (*17)

create_document_type(engine_id String, document_type_id String)

Creates a document type for a specific engine., (*18)

$client->create_document_type('library', 'books');, (*19)

destroy_document_type(engine_id String, document_type_id String)

Destroys a document type., (*20)

$client->destroy_document_type('library', 'books');, (*21)

documents(engine_id String, document_type_id String)

Returns all documents for a certain engine and document type., (*22)

$client->documents('library', 'books');, (*23)

document(engine_id String, document_type_id String, document_id String)

Returns a specific document., (*24)

$client->document('library', 'books', '1');, (*25)

create_document(engine_id String, document_type_id String, document Array)

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'
        )
    )
));

create_or_update_document(engine_id String, document_type_id String, document Array)

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'
        )
    )
));

update_document(engine_id String, document_type_id String, document_id String, fields Array)

Updates a single document with the specified document_id., (*28)

$client->update_document('library', 'books', '1', array('author' => 'Jorbo Bacon'));

update_documents(engine_id String, document_type_id String, documents Array)

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',
        )
    )
));

destroy_document(engine_id String, document_type_id String, document_id String)

Destroys a document., (*30)

$client->destroy_document('library', 'books', '1');, (*31)

destroy_documents(engine_id String, document_type_id String, document_ids Array)

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)

search(engine_id String, [document_type_id String], query String, [options Array])

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
));

suggest(engine_id String, query String, [options Array])

Used for autocompletion. See the documentation for more information., (*36)

$client->suggest('library', 'Bacon', array(
    'search_fields' => 'author'
));

The Versions

10/08 2017

dev-master

9999999-dev https://github.com/Nevon/swiftype-php

A PHP client for Swiftype, a search and autocomplete API for developers.

  Sources   Download

MIT

The Requires

  • php ^5.3