IMPORTANT: No additional bug fixes or documentation updates
will be released for this version. For the latest information, see the
current release documentation.
Workplace Search API
edit
IMPORTANT: This documentation is no longer updated. Refer to Elastic's version policy and the latest documentation.
Workplace Search API
editHere is reported a brief overview of the Workplace Search API. For more information please visit the Workplace Search API documentation.
Content Sources
edituse Elastic\EnterpriseSearch\Client;
use Elastic\EnterpriseSearch\WorkplaceSearch\Request;
use Elastic\EnterpriseSearch\WorkplaceSearch\Schema;
$client = new Client([
'host' => 'http://localhost:3002',
'workplace-search' => [
'token' => '<insert here the API key>'
]
]);
$workplace = $client->workplaceSearch();
// Create a custom content source
$content = new ContentSourceCreateDefinition('test');
$result = $workplace->createContentSource(
new Request\CreateContentSource($content)
);
$sourceId = $result['id'] ?? null;
Documents
edit// Index a document in content source $sourceId
$doc = new Schema\Document();
$doc->id = '1234';
$doc->title = "The Meaning of Time";
$doc->body = "Not much. It is a made up thing.";
$result = $workplace->indexDocuments(
new Request\IndexDocuments($sourceId, [$doc])
);
// Delete documents
$result = $workplace->deleteDocuments(
new Request\DeleteDocuments($sourceId, [$doc->id])
);