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

find query cannot search for string that contains forward slash "/" #312

Closed
mrkprdo opened this issue Jul 19, 2022 · 2 comments · Fixed by #376
Closed

find query cannot search for string that contains forward slash "/" #312

mrkprdo opened this issue Jul 19, 2022 · 2 comments · Fixed by #376

Comments

@mrkprdo
Copy link

mrkprdo commented Jul 19, 2022

I have a string value which is a unix path that has slash, i can set it in db, but cannot query it.
I have set Field(index=True, full_text_search=True).

Afaik, in sql, we can use the keyword LIKE or % escape to query it, how to do it with redis om in FindQuery?

@ninoseki
Copy link
Contributor

Hello, I also have the same problem with redis-om v0.0.27.

Here is a code to reproduce the issue.

from aredis_om import JsonModel, Migrator, Field
import asyncio


class Test(JsonModel):
    name: str = Field(index=True)


async def main():
    await Migrator().run()

    foo = Test(name="/tmp/foo/bar")
    await foo.save()

    results = await Test.find(Test.name == "/tmp/foo/bar").all()
    # this will raise AssertionError
    assert len(results) > 0


asyncio.run(main())

I checked args in execute.

['ft.search', ':__main__.Test:index', '@name:{/tmp/foo/bar}', 'LIMIT', 0, 10]

I guess TokenEscaper should also escape /.

localhost:6379> ft.search :__main__.Test:index @name:{/tmp/foo/bar}
1) (integer) 0

localhost:6379> ft.search :__main__.Test:index @name:{\/tmp\/foo\/bar}
1) (integer) 1

@mrkprdo
Copy link
Author

mrkprdo commented Sep 12, 2022

Thanks @ninoseki @dvora-h

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.

2 participants