本文整理汇总了PHP中Elasticsearch\Client::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::get方法的具体用法?PHP Client::get怎么用?PHP Client::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Elasticsearch\Client
的用法示例。
在下文中一共展示了Client::get方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTitle
public function getTitle(FilePath $path)
{
$params = array('index' => $this->index, 'type' => self::MARKDOWN_DOCUMENT_TYPE, 'id' => $path->toAbsoluteUrlString(), '_source_include' => array('title'));
$result = $this->client->get($params);
if (null === $result) {
return null;
}
return $result['_source']['title'];
}
示例2: testCreateJob
public function testCreateJob()
{
$job = self::$jobFactory->create(uniqid());
$id = self::$jobMapper->create($job);
$res = self::$client->get(['index' => self::$index->getIndexNameCurrent(), 'type' => 'jobs', 'id' => $id]);
$resJob = $res['_source'];
$job = self::$jobMapper->get($id);
$this->assertJob($job, $resJob);
$this->assertEquals($job->getVersion(), $res['_version']);
}
示例3: find
/**
* @param string $identity
* @return Document
*/
public function find($identity)
{
try {
$data = $this->client->get(['index' => $this->index, 'type' => $this->type, 'id' => $identity]);
$documentClass = $this->documentClass;
return $documentClass::deserialize($data['_source']);
} catch (Missing404Exception $e) {
}
return null;
}
示例4: saveDocument
/**
* {@inheritdoc}
*/
public function saveDocument(Searchable $model)
{
$document = $this->constructDocument($model);
if (!$this->indexIsNested($model->getSearchIndex())) {
$this->client->index($document);
return;
}
list($index, $type) = $this->retrieveNestedIndex($model->getSearchIndex());
$class = $this->retrieveParentClass($model->getSearchIndex());
$parent = $model->belongsTo($class, null, null, class_basename($class))->getResults();
$parentData = $this->client->get(['id' => $parent->getKey(), 'type' => $parent->getSearchType(), 'index' => $parent->getSearchIndex()])['_source'];
if (!isset($parentData[$type])) {
$parentData[$type] = [];
}
$children = Collection::make($parentData[$type]);
if ($child = $children->first(function ($child) use($model) {
return $child[$model->getKeyName()] == $model->getKey();
})) {
$newChildren = $children->map(function ($child) use($model) {
if ($child[$model->getKeyName()] == $model->getKey()) {
$child = $model->documentToArray();
if (!isset($document[$model->getKeyName()])) {
$child[$model->getKeyName()] = $model->getKey();
}
}
return $child;
});
} else {
$newChildren = $children->push($model->documentToArray());
}
$this->client->update(['id' => $parent->getKey(), 'type' => $parent->getSearchType(), 'index' => $parent->getSearchIndex(), 'body' => ['doc' => [$type => $newChildren]]]);
}
示例5: find
/**
* @param string $identity
* @return Document
* @throws DocumentNotFoundException
*/
public function find(string $identity) : Document
{
try {
$data = $this->client->get($this->createParams($identity));
return $this->serializer->deserialize($this->serializer->serialize($data['_source']), $this->documentClass);
} catch (Missing404Exception $e) {
throw new DocumentNotFoundException($identity);
}
}
示例6: executeByElasticClient
/**
* Execute the request by elasticsearch client
*
* @param Client $client
* @return ResponseInterface
*/
public function executeByElasticClient(Client $client)
{
$params = $this->toElasticClient();
$responseClass = $this->getResponseClassOfRequest();
/** @var GetResponseInterface $response */
$response = new $responseClass();
$result = RawResponse::build($client->get($params));
if (null !== $this->document) {
$response->setDocument($this->document);
}
$response->build($result);
return $response;
}
示例7: findOne
/**
* Retrieves an entity by its id.
* @param string $id
* @return ElasticsearchEntity the entity with the given id or null if none found
*/
public function findOne($id)
{
try {
$result = $this->elasticsearchClient->get(array('id' => $id, 'index' => $this->index, 'type' => $this->getType()));
if (!$result || !$result['found']) {
return null;
}
$entity = $this->createEntityFromDocument($result);
return $entity;
} catch (Missing404Exception $exc) {
return null;
}
}
示例8: get
/**
* @param GetParams $params
* @return GetResponse
*/
public function get(GetParams $params)
{
return new GetResponse($this->nativeClient->get($params->toArray()));
}
示例9: get
/**
* Get a document index.
*
* @param array $params
*
* @return array
*/
public function get(array $params)
{
return $this->client->get($this->prepareParams($params));
}
示例10: documentGet
/**
* Perform an insertion into the engine.
*
* @param array $payload
* @return array
*/
public function documentGet($payload)
{
return $this->client->get($payload);
}