-
Notifications
You must be signed in to change notification settings - Fork 8
Developer Guide: ESInstance Interface
Abdullah Almsaeed edited this page Aug 30, 2017
·
3 revisions
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.
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;
}
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;