redis/redis-vl-python

Enforce uniqueness of fieldnames

Closed this issue · 0 comments

An easy fix... but this is something we should address to prevent any footguns:

index = SearchIndex.from_dict({"index": {"name": "tyler"}, "fields": {"text": [{"name": "test"}], "vector": [{"name": "test", "dims": 3, "algorithm": "flat"}]}})

for example yields an error from Redis because there is a duplicate field name.

One possibility for fixing this is to flip the schema spec on it's head and make the field name the "key" by which we organize the schema:

index:
    name: hash-test
    prefix: hash
    storage_type: hash

fields:
    sentence:
        - type: text
    embedding:
        - type: vector
          dims: 768
          algorithm: flat
          distance_metric: cosine