ElasticSearcher\Managers\DocumentsManager::exists PHP Метод

exists() публичный Метод

public exists ( string $indexName, string $type, string $id ) : boolean
$indexName string
$type string
$id string
Результат boolean
    public function exists($indexName, $type, $id)
    {
        $index = $this->elasticSearcher->indicesManager()->getRegistered($indexName);
        $params = ['index' => $index->getInternalName(), 'type' => $type, 'id' => $id];
        return $this->elasticSearcher->getClient()->exists($params);
    }

Usage Example

 public function testWithPrefixedIndex()
 {
     $id = 12345;
     $data = ['id' => $id, 'name' => 'Harry Potter and the wizards'];
     // Make sure the document doesn't exist.
     if ($this->documentsManager->exists('books', 'books', $id)) {
         $this->documentsManager->delete('books', 'books', $id);
     }
     $this->documentsManager->index('books', 'books', $data);
     $this->assertTrue($this->documentsManager->exists('books', 'books', $id));
     $this->assertEquals($data, $this->documentsManager->get('books', 'books', $id)['_source']);
 }
All Usage Examples Of ElasticSearcher\Managers\DocumentsManager::exists