@@ -74,27 +74,27 @@ This would correspond to a dataset that looked something like
7474
7575With the schema, the RedisVL library can be used to create, load vectors and perform vector searches
7676` ` ` python
77- import pandas as pd
7877
7978from redisvl.index import SearchIndex
80- from redisvl.query import create_vector_query
79+ from redisvl.query import VectorQuery
8180
82- # define and create the index
83- index = SearchIndex.from_yaml("./users_schema.yml") )
81+ # initialize the index and connect to Redis
82+ index = SearchIndex.from_dict(schema )
8483index.connect("redis://localhost:6379")
85- index.create()
8684
87- index.load(pd.read_csv("./users.csv").to_dict("records"))
85+ # create the index in Redis
86+ index.create(overwrite=True)
8887
89- query = create_vector_query(
90- ["user", "age", "job", "credit_score"],
91- number_of_results=2,
88+ # load data into the index in Redis (list of dicts)
89+ index.load(data)
90+
91+ query = VectorQuery(
92+ vector=[0.1, 0.1, 0.5],
9293 vector_field_name="user_embedding",
94+ return_fields=["user", "age", "job", "credit_score"],
95+ num_results=3,
9396)
94-
95- query_vector = np.array([0.1, 0.1, 0.5]).tobytes()
96- results = index.search(query, query_params={"vector" : query_vector})
97-
97+ results = index.search(query.query, query_params=query.params)
9898
9999```
100100
0 commit comments