logo

English

Get Recommendations

Notice !

Results are cached for 10 minutes and changes (like updating a document) will not be applied for the same query until 10 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):
OptionDescriptionRequiredExample
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'55.22.11.6'
user_countryuser country codeno'CA'
try
{
  $response = $lableb->recommend( 'posts', [
    'id' => 1
  ] );
}
catch( \Lableb\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/v1/....'
    ],
  ]
]