Developing RediSearch

    By invoking the following command, RediSearch module and its submodules are cloned:

    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 ). Docker is even a more agile, as it offers an almost instant solution:

    1. docker exec -it $search bash

    Then, from within the container, cd /build 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 docker exec or commit the state of the container to an image and re-invoke it on a later stage:

    1. docker commit $search redisearch1
    2. docker stop $search
    3. search=$(docker run -d -it -v $PWD:/build rediseatch1 bash)
    4. docker exec -it $search bash

    You can replace debian:buster 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 gnu make installed, you can execute

    1. cd RediSearch
    2. sudo ./system-setup.py

    Note that system-setup.py will install various packages on your system using the native package manager and pip. This requires root permissions (i.e. sudo) on Linux.

    If you prefer to avoid that, you can:

    • Review system-setup.py and 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

    Next, execute the following, to complete dependency acquisition:

    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 sudo ./deps/readies/bin/getredis .

    Getting help

    make help provides a quick summary of the development features.

    Building from source

    To get a glimpse into CMake decesion process, add WHY=1 to the build command. CMake stores its intermediate files in RediSearch/build . Afterwards, one can use:

    or:

    1. cd build
    2. make V=1

    to further diagnose the build process.

    The following will run redis and load RediSearch module.

    1. make run

    You can open in another terminal to interact with it.

    Running tests

    There are several sets of unit tests: * C tests, located in src/tests , run by make c_tests . * C++ tests (enabled by GTest), located in src/cpptests , run by make cpp_tests . * Python tests (enabled by RLTest), located in src/pytests , run by make pytest .

    One can run all tests by invoking make test . A single test can be run using the TEST parameter, e.g. make test TEST=regex .

    Debugging

    Similarly, Python tests in a single-test mode, one can set a breakpoint by using the BB() function inside a test.