Skip to content

Developer Guide: ESInstance Interface

Abdullah Almsaeed edited this page Aug 30, 2017 · 3 revisions

ESInstance Documentation

EsInstance is used as a wrapper around the Elasticsearch\Client::class. It instantiates a new connection to an elasticsearch server and provides wrapper methods to build indices.

Usage Examples

Create a new index

$es = new ESInstance();
$es->setIndexParams('my_index_name')->createIndex();

Search a table index

$es = new ESInstance();
$results = $es->setTableSearchParams('table_index_name', 'index_type', ['content' => 'search term here'])
              ->search();
foreach($results as $result) {
  echo $result->title;
  echo $result->content;
  echo $result->highlight;
  echo $result->url;
}

Direct Access to the Client

You can get direct access to the client through ESInstance, which can be useful if a wrapper method is not available.

$es = new ESInstance();
$client = $es->client;
Clone this wiki locally