Skip to content

Suggesting

Create a suggestion index called “MySuggestions”:

use Ehann\RediSearch\Suggestion;
$suggestion = new Suggestion($redisClient, 'MySuggestions');

Add a suggestion with a score:

$suggestion->add('Tale of Two Cities', 1.10);

Pass a partial string to the get method:

$result = $suggestion->get('Cities');

Pass the entire suggestion string to the delete method:

$result = $suggestion->delete('Tale of Two Cities');

Getting the Number of Possible Suggestions

Section titled “Getting the Number of Possible Suggestions”

Simply use the suggestion index’s length method:

$numberOfPossibleSuggestions = $suggestion->length();