rvl ~ The RedisVL CLI#

RedisVL is a Python library with a dedicated CLI to help load and create vector search indices within Redis.

This notebook will walk through how to use the Redis Vector Library CLI (rvl).

Before running this notebook, be sure to

  1. Have installed redisvl and have that environment active for this notebook.

  2. Have a running Redis instance with the Search and Query capability

# First, see if the rvl tool is installed
!rvl version
20:09:02 [RedisVL] INFO   RedisVL version 0.0.7

Index#

The rvl index command is can be used for a number of tasks related to creating and managing vector indices. Wether you are working in Python or another language, this cli tool can still be useful for managing and inspecting your indices.

first, we will create an index from a yaml schema that looks like the following

version: '0.1.0'

index:
    name: vectorizers
    prefix: doc
    storage_type: hash

fields:
    - name: sentence
      type: text
    - name: embedding
      type: vector
      attrs:
        dims: 768
        algorithm: flat
        distance_metric: cosine
# Create an index from a yaml schema
!rvl index create -s schema.yaml
20:09:04 [RedisVL] INFO   Index created successfully
# list the indices that are available
!rvl index listall
20:09:05 [RedisVL] INFO   Indices:
20:09:05 [RedisVL] INFO   1. vectorizers
# inspect the index fields
!rvl index info -i vectorizers
Index Information:
╭──────────────┬────────────────┬────────────┬─────────────────┬────────────╮
│ Index Name   │ Storage Type   │ Prefixes   │ Index Options   │   Indexing │
├──────────────┼────────────────┼────────────┼─────────────────┼────────────┤
│ vectorizers  │ HASH           │ ['doc']    │ []              │          0 │
╰──────────────┴────────────────┴────────────┴─────────────────┴────────────╯
Index Fields:
╭───────────┬─────────────┬────────┬────────────────┬────────────────╮
│ Name      │ Attribute   │ Type   │ Field Option   │   Option Value │
├───────────┼─────────────┼────────┼────────────────┼────────────────┤
│ sentence  │ sentence    │ TEXT   │ WEIGHT         │              1 │
│ embedding │ embedding   │ VECTOR │                │                │
╰───────────┴─────────────┴────────┴────────────────┴────────────────╯
# delete an index without deleting the data within it
!rvl index delete -i vectorizers
20:09:09 [RedisVL] INFO   Index deleted successfully
# see the index
!rvl index listall
20:09:11 [RedisVL] INFO   Indices:

Stats#

The rvl stats command will return some basic information about the index. This is useful for checking the status of an index, or for getting information about the index to use in other commands.

# create a new index with the same schema
!rvl index create -s schema.yaml
20:09:12 [RedisVL] INFO   Index created successfully
# list the indices that are available
!rvl index listall
20:09:14 [RedisVL] INFO   Indices:
20:09:14 [RedisVL] INFO   1. vectorizers
# see all the stats for the index
!rvl stats -i vectorizers
Statistics:
╭─────────────────────────────┬────────────╮
│ Stat Key                    │ Value      │
├─────────────────────────────┼────────────┤
│ num_docs                    │ 0          │
│ num_terms                   │ 0          │
│ max_doc_id                  │ 0          │
│ num_records                 │ 0          │
│ percent_indexed             │ 1          │
│ hash_indexing_failures      │ 0          │
│ number_of_uses              │ 1          │
│ bytes_per_record_avg        │ nan        │
│ doc_table_size_mb           │ 0          │
│ inverted_sz_mb              │ 0          │
│ key_table_size_mb           │ 0          │
│ offset_bits_per_record_avg  │ nan        │
│ offset_vectors_sz_mb        │ 0          │
│ offsets_per_term_avg        │ nan        │
│ records_per_doc_avg         │ nan        │
│ sortable_values_size_mb     │ 0          │
│ total_indexing_time         │ 0          │
│ total_inverted_index_blocks │ 0          │
│ vector_index_sz_mb          │ 0.00818634 │
╰─────────────────────────────┴────────────╯
!rvl index destroy -i vectorizers
20:09:33 [RedisVL] INFO   Index deleted successfully