/** * Find all IDs that match a search under a namespace * @param string $term * @param string $namespace * @return array */ public function find(string $term, string $namespace) : array { $term = Str::clean($term); return $this->redis->smembers("autocomplete:{$term}:{$namespace}"); }
/** * Find all IDs that match a search under a namespace * @param string $term * @param string $namespace * @return array */ public function find(string $term, string $namespace) : array { $namespaced = $this->data[$namespace] ?? []; return $namespaced[Str::clean($term)] ?? []; }
/** * Create a new index * @param string $id * @param string $term * @return void */ public function __construct(string $id, string $term) { $this->id = $id; $this->term = Str::clean($term); }