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

FT.SEARCH command gives me error: ERR: Query Syntax Error (this issue does work with Redis) #3258

Open
wernermorgenstern opened this issue Jul 2, 2024 · 9 comments
Assignees
Labels
bug Something isn't working

Comments

@wernermorgenstern
Copy link

Describe the bug
I create an index (see below), and I am trying to run this query:
ft.search cmd-idx "@tid:{abc} @path:{myCmd} @status:{waiting} @updated:[1719951363 +inf]"

Index is:

        'cmd-idx',
        'ON',
        'HASH',
        'PREFIX',
        1,
        'cmd:',
        'SCHEMA',
        'tid',
        'TAG',
        'code',
        'NUMERIC',
        'msgId',
        'NUMERIC',
        'path',
        'TAG',
        'status',
        'TAG',
        'tags',
        'TAG',
        'created',
        'NUMERIC',
        'SORTABLE',
        'updated',
        'NUMERIC',
        'SORTABLE',
        'sent',
        'NUMERIC',
        'SORTABLE'
      ]

To Reproduce
Steps to reproduce the behavior:

  1. Create index with FT.create
  2. Query records using ft.search cmd-idx "@tid:{abc} @path:{myCmd} @status:{waiting} @updated:[1719951363 +inf]"
  3. Error: ERR Query syntax error

Expected behavior
Supposed to return records (0 or more)

Environment (please complete the following information):

  • OS: [macOs M1, in docker]
  • Kernel: # Command: Darwin local 23.5.0 Darwin Kernel Version 23.5.0: Wed May 1 20:12:58 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000 arm64
  • Containerized?: [Docker Compose
  • Dragonfly Version: dragonfly v1.19.2-2ff628203925b206c4a1031aa24916523dc5382e
    build time: 2024-07-02 06:22:16

Additional context
This works with Redis

@wernermorgenstern wernermorgenstern added the bug Something isn't working label Jul 2, 2024
@wernermorgenstern
Copy link
Author

So the command I specified will work

However, if my search for the tid contains a dash/hyphen, that is when the error occurs

ft.search cmd-idx "@tid:{abc-1} @path:{myCmd} @status:{waiting} @Updated:[1719951363 +inf]"

@dranikpg
Copy link
Contributor

dranikpg commented Jul 4, 2024

Yes, our current parser isn't that advanced to handle all the edge cases, #3145

Meanwhile, you can use quoted 'text-with-hypens and even --spaces--' - strings with quotes ' ' or " " 🙂

@romange
Copy link
Collaborator

romange commented Jul 5, 2024

@dranikpg your comment is not very clear, seems that the formatting is broken. can you please fix and provide concrete examples on how it should look like?

@dranikpg
Copy link
Contributor

dranikpg commented Jul 5, 2024

it's not broken, I just quoted the text in a weird way 😅 It should just have quotes around the terms, like this

ft.search cmd-idx "@tag{'tag with spaces'}"

@wernermorgenstern
Copy link
Author

@dranikpg @romange , so just wondering, why does it work with Redis (unquoted)? Not dragonfly?
Is that a undocumented feature in Redis?

@BorysTheDev
Copy link
Contributor

@wernermorgenstern It looks like a bug @dranikpg has suggested a workaround for you while I'm fixing this bug

@BorysTheDev
Copy link
Contributor

BorysTheDev commented Jul 6, 2024

@wernermorgenstern I can not reproduce your case on the main branch and 1.19.2 on Linux and got the correct result.

127.0.0.1:6379> FT.CREATE cmd-idx ON HASH PREFIX 1 cmd: SCHEMA tid TAG code NUMERIC msgId NUMERIC path TAG status TAG tags TAG created NUMERIC SORTABLE updated NUMERIC SORTABLE sent NUMERIC SORTABLE
OK
127.0.0.1:6379> ft.search cmd-idx "@tid:{abc} @path:{myCmd} @status:{waiting} @updated:[1719951363 +inf]"
1) (integer) 0

I will ask somebody to check it on MacOs. I would appreciate if you check it one more time, or check that I run exactly the same commands as you do

@wernermorgenstern
Copy link
Author

wernermorgenstern commented Jul 6, 2024 via email

@BorysTheDev
Copy link
Contributor

@wernermorgenstern Thx. I missed your comment. It's reproducible now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants