dragonflydb / dragonfly

A modern replacement for Redis and Memcached
https://www.dragonflydb.io/
Other
24.51k stars 885 forks source link

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

Open wernermorgenstern opened 5 days ago

wernermorgenstern commented 5 days ago

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):

Additional context This works with Redis

wernermorgenstern commented 5 days ago

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 commented 3 days ago

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 commented 3 days ago

@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 commented 2 days ago

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 commented 2 days ago

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

BorysTheDev commented 2 days ago

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

BorysTheDev commented 1 day ago

@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 commented 1 day ago

There is another comment, when you search for a string like abc-123

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: Borys @.> Sent: Saturday, July 6, 2024 8:17:09 AM To: dragonflydb/dragonfly @.> Cc: Werner Morgenstern @.>; Mention @.> Subject: Re: [dragonflydb/dragonfly] FT.SEARCH command gives me error: ERR: Query Syntax Error (this issue does work with Redis) (Issue #3258)

@wernermorgensternhttps://github.com/wernermorgenstern I can not reproduce your case on the main branch 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 @.***https://github.com/tid:{abc} @pathhttps://github.com/path:{myCmd} @status:{waiting} @Updatedhttps://github.com/Updated:[1719951363 +inf]"

  1. (integer) 0 `

— Reply to this email directly, view it on GitHubhttps://github.com/dragonflydb/dragonfly/issues/3258#issuecomment-2211753705, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AJPN7C5DKHLRMBEFH6M33TLZK7N4LAVCNFSM6AAAAABKIIFZBOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMJRG42TGNZQGU. You are receiving this because you were mentioned.Message ID: @.***>

BorysTheDev commented 1 day ago

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