Skip to content


RediSearch-PHP is a PHP client library for the RediSearch module which adds full-text search to Redis.



composer install ethanhann/redisearch-php


require_once 'vendor/autoload.php';

Create a Redis Client

use Ehann\RediSearch\Redis\PredisAdapter;
use Ehann\RediSearch\Redis\PhpRedisAdapter;
use Ehann\RediSearch\Redis\RedisClientAdapter;

$redis = (new PredisAdapter())->connect('', 6379);
// or
$redis = (new PhpRedisAdapter())->connect('', 6379);
// or
$redis = (new RedisClientAdapter())->connect('', 6379);

Create the Schema

use Ehann\RediSearch\Index;

$bookIndex = new Index($redis);


Add a Document

    new TextField('title', 'Tale of Two Cities'),
    new TextField('author', 'Charles Dickens'),
    new NumericField('price', 9.99),
    new NumericField('stock', 231),

Search the Index

$result = $bookIndex->search('two cities');

$result->count();     // Number of documents.
$result->documents(); // Array of matches.

// Documents are returned as objects by default.
$firstResult = $result->documents()[0];