|
1 |
| -# RediSearch Data Loader |
2 |
| -The purpose of this script is to assist in loading datasets to a RediSearch instance efficiently. |
| 1 | +# RedisVL |
3 | 2 |
|
4 |
| -The project is brand new and will undergo improvements over time. |
| 3 | +A CLI and Library to help with loading data into Redis specifically for |
| 4 | +usage with RediSearch and Redis Vector Search capabilities |
5 | 5 |
|
6 |
| -## Getting Started |
| 6 | +### Usage |
7 | 7 |
|
8 |
| -### Requirements |
9 |
| -Install the Python requirements listed in `requirements.txt`. |
10 |
| - |
11 |
| -```bash |
12 |
| -$ pip install -r requirements.txt |
13 | 8 | ```
|
| 9 | +usage: redisvl <command> [<args>] |
14 | 10 |
|
15 |
| -### Data |
16 |
| -In order to run the script you need to have a dataset that contains your vectors and metadata. |
| 11 | +Commands: |
| 12 | + load Load vector data into redis |
| 13 | + index Index manipulation (create, delete, etc.) |
| 14 | + query Query an existing index |
17 | 15 |
|
18 |
| ->Currently, the data file must be a pickled pandas dataframe. Support for more data types will be included in future iterations. |
| 16 | +Redis Vector load CLI |
19 | 17 |
|
20 |
| -### Schema |
21 |
| -Along with the dataset, you must update the dataset schema for RediSearch in [`data/schema.py`](data/schema.py). |
| 18 | +positional arguments: |
| 19 | + command Subcommand to run |
22 | 20 |
|
23 |
| -### Running |
24 |
| -The `main.py` script provides an entrypoint with optional arguments to upload your dataset to a Redis server. |
| 21 | +optional arguments: |
| 22 | + -h, --help show this help message and exit |
25 | 23 |
|
26 |
| -#### Usage |
27 |
| -``` |
28 |
| -python main.py |
29 |
| -
|
30 |
| - -h, --help Show this help message and exit |
31 |
| - --host Redis host |
32 |
| - -p, --port Redis port |
33 |
| - -a, --password Redis password |
34 |
| - -c , --concurrency Amount of concurrency |
35 |
| - -d , --data Path to data file |
36 |
| - --prefix Key prefix for all hashes in the search index |
37 |
| - -v , --vector Vector field name in df |
38 |
| - -i , --index Index name |
39 | 24 | ```
|
40 | 25 |
|
41 |
| -#### Defaults |
| 26 | +For any of the above commands, you will need to have an index schema written |
| 27 | +into a yaml file for the cli to read. The format of the schema is as follows |
| 28 | + |
| 29 | +```yaml |
| 30 | +index: |
| 31 | + name: sample # index name used for querying |
| 32 | + storage_type: hash |
| 33 | + key_field: "id" # column name to use for key in redis |
| 34 | + prefix: vector # prefix used for all loaded docs |
| 35 | + |
| 36 | +# all fields to create index with |
| 37 | +# sub-items correspond to redis-py Field arguments |
| 38 | +fields: |
| 39 | + tag: |
| 40 | + categories: # name of a tag field used for queries |
| 41 | + separator: "|" |
| 42 | + year: # name of a tag field used for queries |
| 43 | + separator: "|" |
| 44 | + vector: |
| 45 | + vector: # name of the vector field used for queries |
| 46 | + datatype: "float32" |
| 47 | + algorithm: "flat" # flat or HSNW |
| 48 | + dims: 768 |
| 49 | + distance_metric: "cosine" # ip, L2, cosine |
| 50 | +``` |
42 | 51 |
|
43 |
| -| Argument | Default | |
44 |
| -| ----------- | ----------- | |
45 |
| -| Host | `localhost` | |
46 |
| -| Port | `6379` | |
47 |
| -| Password | "" | |
48 |
| -| Concurrency | `50` | |
49 |
| -| Data (Path) | `data/embeddings.pkl` | |
50 |
| -| Prefix | `vector:` | |
51 |
| -| Vector (Field Name) | `vector` | |
52 |
| -| Index Name | `index` | |
| 52 | +#### Example Usage |
53 | 53 |
|
| 54 | +```bash |
| 55 | +# load in a pickled dataframe with |
| 56 | +redisvl load -s sample.yml -d embeddings.pkl |
| 57 | +``` |
54 | 58 |
|
55 |
| -#### Examples |
| 59 | +```bash |
| 60 | +# load in a pickled dataframe to a specific address and port |
| 61 | +redisvl load -s sample.yml -d embeddings.pkl -h 127.0.0.1 -p 6379 |
| 62 | +``` |
56 | 63 |
|
57 |
| -Load to a local (default) redis server with a custom index name and with concurrency = 100: |
58 | 64 | ```bash
|
59 |
| -$ python main.py -d data/embeddings.pkl -i myIndex -c 100 |
| 65 | +# load in a pickled dataframe to a specific |
| 66 | +# address and port and with password |
| 67 | +redisvl load -s sample.yml -d embeddings.pkl -h 127.0.0.1 -p 6379 -p supersecret |
60 | 68 | ```
|
61 | 69 |
|
62 |
| -Load to a cloud redis server with all other defaults: |
| 70 | +### Support |
| 71 | + |
| 72 | +#### Supported Index Fields |
| 73 | + |
| 74 | + - ``geo`` |
| 75 | + - ``tag`` |
| 76 | + - ``numeric`` |
| 77 | + - ``vector`` |
| 78 | + - ``text`` |
| 79 | +#### Supported Data Types |
| 80 | + - Pandas DataFrame (pickled) |
| 81 | +#### Supported Redis Data Types |
| 82 | + - Hash |
| 83 | + - JSON (soon) |
| 84 | + |
| 85 | +### Install |
| 86 | +Install the Python requirements listed in `requirements.txt`. |
| 87 | + |
63 | 88 | ```bash
|
64 |
| -$ python main.py -h {redis-host} -p {redis-port} -a {redis-password} |
65 |
| -``` |
| 89 | +git clone https://github.com/RedisVentures/data-loader.git |
| 90 | +cd redisvl |
| 91 | +pip install . |
| 92 | +``` |
| 93 | + |
| 94 | +### Creating Input Data |
| 95 | +#### Pandas DataFrame |
| 96 | + |
| 97 | + more to come, see tests and sample-data for usage |
0 commit comments