From 5114c302cd902e734070d1b3cbda3e8d1c86c73e Mon Sep 17 00:00:00 2001 From: Yasuhiro Horimoto Date: Mon, 19 Aug 2019 23:05:01 +0900 Subject: [PATCH 1/2] Add a Groonga::Query for binding "grn_expr_syntax_escape_query()" --- lib/groonga/query.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 lib/groonga/query.rb diff --git a/lib/groonga/query.rb b/lib/groonga/query.rb new file mode 100644 index 00000000..c4eed767 --- /dev/null +++ b/lib/groonga/query.rb @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2019 Horimoto Yasuhiro +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1 as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +class Groonga + module Query + class << self + def expand(query, expander, flags) + + end + end + end +end From d302c5bbc13630af08008ec80e51388e5ccf74b5 Mon Sep 17 00:00:00 2001 From: Yasuhiro Horimoto Date: Tue, 3 Sep 2019 21:09:44 +0900 Subject: [PATCH 2/2] test: add a test for query expand --- test/test-query.rb | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 test/test-query.rb diff --git a/test/test-query.rb b/test/test-query.rb new file mode 100644 index 00000000..6e34902b --- /dev/null +++ b/test/test-query.rb @@ -0,0 +1,30 @@ +# Copyright (C) 2019 Horimoto Yasuhiro +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1 as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +class QueryTest < Test::Unit::TestCase + include GroongaTestUtils + + def setup + @query = Groonga::Query.new + end + + def test_expand + expanded_query = @query.expand(:query => "Groonga", + :expander => "QueryExpanderTSV", + :flags => 0) + assert_equal("((Groonga) OR (Mroonga) OR (PGroonga) OR (Rroonga))", + expanded_query) + end +end