Documentation - Redise Pack

A guide to Redise Pack installation, operation and administration

open all | close all

Quick Start with RediSearch

Note: This page only pertains to Redis Enterprise Pack v5.0 Preview.

For this quick start, you will need the following:

Add RediSearch Module to Redise Pack Cluster

Before doing anything, you must download and install a utility

You will need a few things:

  1. Python must be installed
  2. pip – for python package installation
    For ubuntu:

    $ apt-get install python-pip

    For RHEL/Centos:

    $ yum install python-pip
  3. The utility
    $ pip install git+https://github.com/RedisLabs/rmadm@master

Set up environment variables

$ export RL_USER="myuser@domain.com"
$ export RL_PASS="mypassword"

Download the module

$ curl -O https://s3.amazonaws.com/redismodules/redisearch/redisearch.Linux-x86_64.latest.zip

Install the module into the cluster

$ curl -k -u "<admin-username>:<password>" -F \
"module=@/<path-to-file>/redisearch.Linux-x86_64.latest.zip" \
http://<your-rp-cluster>:8080/v1/modules

Lastly, create a simple database which enables RediSearch:

$ curl -k -X POST -u "<admin-username>:<password>" -H "Content-Type: application/json" \
-d '{ "name": "test2", "port": 12544, "version": "4.0", "memory_size": 1000000, "type": "redis", "module_list":["c7f15d6fc15b2d5324d2a5e38f667032"],
"module_list_args":["",""] }' http://<your-rp-cluster>:8080/v1/bdbs

Creating Indexes
Let’s create a new index called “myidx”. When you define the index, you must pass in the structure of the data you will be adding to the index. In this example, we have 3 things we input, the title, body, and url. In this example, we have three TEXT and one NUMERIC values. The title has a weight of 5.0.

127.0.0.1:12544> FT.CREATE myIdx SCHEMA title TEXT WEIGHT 5.0 body TEXT url TEXT value NUMERIC

Add info to test index

Now add some data to this index. We will add an object which key will be doc1 and then adds a title of “hello world”, body of “my favorite object”, and url of “https://redislabs.com/” to the object as follows:

127.0.0.1:12544> FT.ADD myIdx doc1 1.0 FIELDS title "hello world" body "My first object" url "https://redislabs.com/"
OK

Search the Index
Do a search on this index for any object with the word “first”:

127.0.0.1:12544> FT.SEARCH myIdx "first" LIMIT 0 10
1) (integer) 1
2) "doc1"
3) 1) "title"
2) "hello world"
3) "body"
4) "My first object"
5) "url"
6) "https://redislabs.com/"

Drop the Index
Now that we are done with it, we can drop the index.

127.0.0.1:12544> FT.DROP myIdx
OK

Auto-Complete and Search Engine Suggestions
Let’s add a suggestion for the search engine to use

127.0.0.1:6379> FT.SUGADD autocomplete "hello world" 100
OK

Make sure the suggestion is there:

127.0.0.1:6379> FT.SUGGET autocomplete "he"
1) "hello world"