Psonic API doc

June 17, 2021 ยท View on GitHub

You need to instantiate the Psonic/Search class to do the searching operations on sonic

<?php
$password = 'SecretPassword';
$search = new Psonic/Search(new Psonic/Client($host, $port, $timeout));
echo $search->connect($password);

after connecting to Search channel you can call the following methods on it

MethodsDescription
->query(string $collection, string $bucket, string $terms, [int $limit], [int $offset], [string <locale>]): arrayReturns an array of matched object identifiers, locale is optional, which should be a valid ISO 639-3 locale (eng = English), if set to none lexing will be disabled
->suggest(string $collection, string $bucket, string $terms, [int $limit]): arrayReturns an array of strings of autosuggestions, locale is optional, which should be a valid ISO 639-3 locale (eng = English), if set to none lexing will be disabled
->ping(): stringPings the server, should return PONG
->disconnect()Disconnects the channel

Ingest

You need to instantiate the Psonic/Ingest class to do the indexing operations on sonic

<?php
$password = 'SecretPassword';
$ingest = new Psonic/Ingest(new Psonic/Client($host, $port, $timeout));
echo $ingest->connect($password);

after connecting to Ingest channel you can call the following methods on it

MethodsDescription
->push(string $collection,string $bucket, string $object_id, string "data", [string <locale>])Add an item to index and Returns a Sonic Response, locale is optional, which should be a valid ISO 639-3 locale (eng = English), if set to none lexing will be disabled
->pop(string $collection,string $bucket, string $object_id, string "data"pops an item out of index and returns a Sonic Response
->count(string $collection,[string $bucket, [string $object_id]]): intcounts the number of items in collection, bucket or object
->flushc(string $collection):intFlushes the objects from a collection, returns a integer saying the number of items flushed
->flushb(string $collection, string $bucket):intFlushes the objects from a bucket, returns a integer saying the number of items flushed
->flusho(string $collection, string $bucket, string $object_id):intFlushes the indexed text from an objects, returns a integer saying the number of items flushed
->ping(): stringPings the server, should return PONG
->disconnect()Disconnects the channel

Control

You need to instantiate the Psonic/Control class to do the control operations on sonic

<?php
$password = 'SecretPassword';
$control = new Psonic/Control(new Psonic/Client($host, $port, $timeout));
echo $control->connect($password);

after connecting to control channel you can call the following methods on it

MethodsDescription
->trigger(string $command)Trigger a control command
->consolidate()Saves the data to disk, when a certain number of items are pushed to index, depending on the configuration it can happen automatically. But to be on the safe side you could call this command manually
->ping(): stringPings the server, should return PONG
->info()Get the information about the server
->disconnect()Disconnects the channel