Developing RediSearch ¶
Developing RediSearch involves setting up the development environment (which can be either Linux-based or macOS-based), building RediSearch, running tests and benchmarks, and debugging both the RediSearch module and its tests.
Cloning the git repository ¶
By invoking the following command, RediSearch module and its submodules are cloned:
git clone --recursive https://github.com/RediSearch/RediSearch.git
Working in an isolated environment ¶
There are several reasons to develop in an isolated environment, like keeping your workstation clean, and developing for a different Linux distribution. The most general option for an isolated environment is a virtual machine (it's very easy to set one up using Vagrant ). Docker is even a more agile, as it offers an almost instant solution:
search=$(docker run -d -it -v $PWD:/build debian:buster bash) docker exec -it $search bash
Then, from within the container,
and go on as usual.
In this mode, all installations remain in the scope of the Docker container.
Upon exiting the container, you can either re-invoke it with the above
or commit the state of the container to an image and re-invoke it on a later stage:
docker commit $search redisearch1 docker stop $search search=$(docker run -d -it -v $PWD:/build rediseatch1 bash) docker exec -it $search bash
You can replace
with your OS of choice, with the host OS being the best choice (so you can run the RediSearch binary on your host once it is built).
Installing prerequisites ¶
To build and test RediSearch one needs to install several packages, depending on the underlying OS. Currently, we support the Ubuntu/Debian, CentOS, Fedora, and macOS.
If you have
installed, you can execute,
sudo make setup
Alternatively, invoke the following (with
will install various packages on your system
using the native package manager and pip.
If you prefer to avoid that, you can:
system-setup.pyand install packages manually,
- Use an isolated environment like explained above,
Use a Python virtual environment, as Python installations are known to be sensitive when not used in isolation:
python2 -m virtualenv venv; . ./venv/bin/activate
Installing Redis ¶
As a rule of thumb, you're better off running the latest Redis version.
If your OS has a Redis 6.x package, you can install it using the OS package manager.
Otherwise, you can invoke
Getting help ¶
provides a quick summary of the development features.
Building from source ¶
will build RediSearch.
To enable unit tests, add
Note that RediSearch uses
as its build system.
will invoke both CMake and the subsequent make command that's required to complete the build.
to remove built artifacts.
make clean ALL=1
will remove the entire
Diagnosing CMake ¶
To get a glimpse into CMake decesion process, add
to the build command.
CMake stores its intermediate files in
Afterwards, one can use:
cd build make -n
cd build make V=1
to further diagnose the build process.
Running Redis with RediSearch ¶
The following will run
and load RediSearch module.
You can open
in another terminal to interact with it.
Running tests ¶
There are several sets of unit tests:
* C tests, located in
, run by
* C++ tests (enabled by GTest), located in
, run by
* Python tests (enabled by RLTest), located in
, run by
One can run all tests by invoking
A single test can be run using the
make test TEST=regex
To build for debugging (enabling symbolic information and disabling optimization), run
One can the use
make run DEBUG=1
In addition to the usual way to set breakpoints in
, it is possible to use the
macro to set a breakpoint inside RediSearch code. It will only have an effect when running under
Similarly, Python tests in a single-test mode, one can set a breakpoint by using the
function inside a test.