From 08bc69f0427c961e8f92aed53cec1b8088b8b047 Mon Sep 17 00:00:00 2001 From: PragmaTwice Date: Thu, 12 Dec 2024 12:44:21 +0800 Subject: [PATCH] feat(search): add TAGGED as an alternative syntax to HASTAG Signed-off-by: PragmaTwice --- src/search/README.md | 1 + src/search/sql_parser.h | 3 ++- tests/cppunit/sql_parser_test.cc | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/search/README.md b/src/search/README.md index 022ec750960..1fb4bbbed1d 100644 --- a/src/search/README.md +++ b/src/search/README.md @@ -32,3 +32,4 @@ Note that when interacting with users, we also refer to KQIR as *Kvrocks Search* - [KQIR: a query engine for Apache Kvrocks that supports both SQL and RediSearch queries](https://kvrocks.apache.org/blog/kqir-query-engine) - [Index encoding format for Kvrocks Search](https://kvrocks.apache.org/community/kvrocks-search-index-encoding) +- [User documentation of Kvrocks Search](https://kvrocks.apache.org/docs/kvrocks-search) diff --git a/src/search/sql_parser.h b/src/search/sql_parser.h index 751b0b47aa2..f90195bd942 100644 --- a/src/search/sql_parser.h +++ b/src/search/sql_parser.h @@ -35,7 +35,8 @@ struct StringOrParam : sor {}; struct NumberOrParam : sor {}; struct HasTag : string<'h', 'a', 's', 't', 'a', 'g'> {}; -struct HasTagExpr : WSPad, StringOrParam>> {}; +struct Tagged : string<'t', 'a', 'g', 'g', 'e', 'd'> {}; +struct HasTagExpr : WSPad>, StringOrParam>> {}; struct NumericAtomExpr : WSPad> {}; struct NumericCompareOp : sor', '='>, one<'=', '<', '>'>> {}; diff --git a/tests/cppunit/sql_parser_test.cc b/tests/cppunit/sql_parser_test.cc index 9173d4c3f3b..e7a4712193f 100644 --- a/tests/cppunit/sql_parser_test.cc +++ b/tests/cppunit/sql_parser_test.cc @@ -117,6 +117,7 @@ TEST(SQLParserTest, Simple) { AssertIR(Parse("select a from b where y > 2"), "select a from b where y > 2"); AssertIR(Parse("select a from b where 3 >= z"), "select a from b where z <= 3"); AssertIR(Parse("select a from b where x hastag \"hi\""), "select a from b where x hastag \"hi\""); + AssertIR(Parse("select a from b where x tagged \"hi\""), "select a from b where x hastag \"hi\""); AssertIR(Parse(R"(select a from b where x hastag "a\nb")"), R"(select a from b where x hastag "a\nb")"); AssertIR(Parse(R"(select a from b where x hastag "")"), R"(select a from b where x hastag "")"); AssertIR(Parse(R"(select a from b where x hastag "hello , hi")"), R"(select a from b where x hastag "hello , hi")");