Suggesting
Creating a Suggestion Index
Section titled “Creating a Suggestion Index”Create a suggestion index called “MySuggestions”:
use Ehann\RediSearch\Suggestion;
$suggestion = new Suggestion($redisClient, 'MySuggestions');Adding a Suggestion
Section titled “Adding a Suggestion”Add a suggestion with a score:
$suggestion->add('Tale of Two Cities', 1.10);Getting a Suggestion
Section titled “Getting a Suggestion”Pass a partial string to the get method:
$result = $suggestion->get('Cities');Deleting a Suggestion
Section titled “Deleting a Suggestion”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();