Get Recommendations

Notice !

Results are cached for 5 minutes approximately and changes (like updating a document) will not be applied for the same query until 5 minutes pass.
To fetch other posts that are related to some post
$lableb->recommend( $collection, $options, [$handler] )
  1. $collection: collection name you want to search for recommendations in.
  2. $options: an associative describing the source document.
  3. $handler: an optional parameter that has the value of recommend by default, specify it if you want to use a custom search handler.
Source document parameters (\$options):
idID of the source documentyes1
titletitle of the source documentno'How to make italian pizza'
urlurl of the source documentno'https://funfunfood.com/2018/12/06/pizza'
limithow many documents to fetchno5
user_ida unique user idno1254
user_ipuser IP addressno''
user_countryuser country codeno'CA'
  $response = $lableb->recommend( 'posts', [
    'id' => 1
  ] );
catch( \Lableb\Exceptions\LablebException $e )
  echo $e->getMessage();

Example response:
  'totalDocuments' => 50,
  'results' => [
      'id' => 1,
      'title' => 'How to make italian pizza',
      'content' => 'The italian pizza, margherita ...',
      'date' => '2018-12-06T12:16:00.000+0000',
      'url' => 'https://funfunfood.com/2018/12/06/pizza',
      'image' => 'https://funfunfood.com/static/pizza.png',
      'feedbackUrl' => 'https://api-bahuth.lableb.com/api/v2/....'
  'totalFacets' => 0
  'facets' => Array


Each result will have an additional field called feedbackUrl which you can perform a GET request on to submit recommend feedback.