Skip to content

Index isn't created correctly when using full text search field? #42

Closed
@simonprickett

Description

@simonprickett

I don't think the index is getting created correctly when using a full text search field... here a field description_fts is created in the index, but it doesn't say to use the field description as the field to search in... so I am unable to do any full text queries on description:

Model:

from typing import Text
from redis_om import (Field, HashModel)

class Adoptable(HashModel):
    name: str = Field(index=True)
    species: str = Field(index=True)
    age: int = Field(index=True)
    weight: float = Field(index=True)
    sex: str = Field(index=True)
    fee: float = Field(index=True)
    children: str = Field(index=True)
    other_animals: str = Field(index=True)
    description: str = Field(index=True, full_text_search=True)

FT.CREATE Redis command generated when I run migrator as seen by Redis MONITOR command:

"ft.create" ":adoptable.Adoptable:index" "ON" "HASH" "PREFIX" "1" ":adoptable.Adoptable:" "SCHEMA" "pk" "TAG" "SEPARATOR" "|" "name" "TAG" "SEPARATOR" "|" "species" "TAG" "SEPARATOR" "|" "age" "NUMERIC" "weight" "NUMERIC" "sex" "TAG" "SEPARATOR" "|" "fee" "NUMERIC" "children" "TAG" "SEPARATOR" "|" "other_animals" "TAG" "SEPARATOR" "|" "description" "TAG" "SEPARATOR" "|" "description_fts" "TEXT"

Hashes created using .save() don't have a description_fts field so this doesn't appear to work. Probably needs something like this in the index create command:

"description" "AS" "description_fts" "TEXT" 

I think the issue is here

f"{name}_fts TEXT"

which should likely say:

f"{name} AS {name}_fts TEXT "

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions