Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
simonprickett opened this issue Dec 9, 2021 · 1 comment · Fixed by #43
Closed

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

simonprickett opened this issue Dec 9, 2021 · 1 comment · Fixed by #43

Comments

@simonprickett
Copy link
Contributor

simonprickett commented Dec 9, 2021

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 "
simonprickett pushed a commit to simonprickett/redis-om-python that referenced this issue Dec 9, 2021
Adds field name alias to fix full text searches.

Closes redis#42
@simonprickett
Copy link
Contributor Author

Available in v0.0.16 https://pypi.org/project/redis-om/0.0.16/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant