logo

English

Index Documents

$lableb->index( $collection, $documents )
  1. $collection: what collection you want to index documents on, e.x posts.
  2. $documents: a document or an array of documents to be indexed.

Example:


$collection = 'posts';
$documents = [
  [
    'id' => 1,
    'title_t_bi' => 'Using the php sdk',
    'contnet_t_bi' => 'Lableb cloud search php sdk',
    'date_dta' => [ '2013-02-05', new DateTime(), date('Y-d-m') ]
  ]
];

try
{
  $response = $lableb->index( $collection, $documents );
}
catch ( \Lableb\LablebException $e )
{
  echo $e->getStatus();
  echo $e->getMessage();
}


Example response:

[
  "indexed" => true,
  "message" => "2 documents has been indexed"
]

Update Indexed Documents

To update an indexed document, just re-index the document with the same ID.