crassaert / php-azure-search
PHP wrapper to query Microsoft Azure Search REST API
Installs: 2 389
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
Requires (Dev)
- phpunit/phpunit: 5.0.*
This package is not auto-updated.
Last update: 2024-12-21 20:08:32 UTC
README
PHP wrapper to query Microsoft Azure Search REST API by Cédric Rassaert.
It's strongly recommended to have a Microsoft SQL Server or Azure DocumentDB as data source.
Basic Usage
New search instance :
$search = new AzureSearch(AZURE_SEARCH_HOST, AZURE_SEARCH_KEY);
with :
AZURE_SEARCH_HOST = https://[service name].search.windows.net
AZURE_SEARCH_KEY = Admin key provided by Azure
Add a datasource
Feel free to use your Microsoft SQL or DocumentDB host.
$search->getSourceRequest()->createSource('actions',
array('name' => 'my_source',
'type' => 'documentdb', // azuresql or documentdb
'credentials' => array('connectionString' => AZURE_DB_CONNECT_STRING),
'container' => array('name' => AZURE_DB_CONTAINER_NAME)));
Add an index
You can add many fields into your index
$fields = array();
$fields[] = array('name' => 'id', 'type' => 'Edm.String', 'key' => true);
$fields[] = array('name' => 'name', 'type' => 'Edm.String', 'key' => false);
$search->getIndexRequest()->createIndex('my_index',
array('name' => 'my_index',
'fields' => $fields));
Add an indexer
$search->getIndexerRequest()->updateIndexer('actions',
array(
'name' => 'actions',
'dataSourceName' => 'my_source',
'targetIndexName' => 'my_index',
'schedule' => array('interval' => 'PT30M',
'startTime' => date('c')
)
));
Searching
$data = $search->getDocumentRequest()->searchDocument('my_index',
array(
'search' => 'my search string'
)
);
You can find all options on Microsoft Azure Website