# Copyright(C) 2014 Kouhei Sutou <kou@clear-code.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# 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

--source ../../../../../../include/mroonga/have_mroonga.inc

--disable_warnings
DROP TABLE IF EXISTS memos;
--enable_warnings

SET NAMES utf8mb4;
CREATE TABLE memos (
  title VARCHAR(255),
  tag1 VARCHAR(10),
  tag2 VARCHAR(10),
  tag3 VARCHAR(10),
  tag4 VARCHAR(10),
  tag5 VARCHAR(10),
  tag6 VARCHAR(10),
  tag7 VARCHAR(10),
  tag8 VARCHAR(10),
  tag9 VARCHAR(10),
  tag10 VARCHAR(10),
  FULLTEXT INDEX (tag1, tag2, tag3, tag4, tag5, tag6, tag7, tag8, tag9, tag10)
) DEFAULT CHARSET=utf8mb4;

INSERT INTO memos
       VALUES("Groonga",
              "tag 1",
              "tag 2",
              "tag 3",
              "tag 4",
              "tag 5",
              "tag 6",
              "tag 7",
              "tag 8",
              "tag 9",
              "tag 10");

SELECT title,
       MATCH(tag1, tag2, tag3, tag4, tag5, tag6, tag7, tag8, tag9, tag10)
       AGAINST("*W1:2,2:4,3:6,4:8,5:10,6:12,7:14,8:16,9:18,10:20 +tag"
               in BOOLEAN MODE) AS score
  FROM memos
  WHERE MATCH(tag1, tag2, tag3, tag4, tag5, tag6, tag7, tag8, tag9, tag10)
        AGAINST("*W1:2,2:4,3:6,4:8,5:10,6:12,7:14,8:16,9:18,10:20 +tag"
                in BOOLEAN MODE);

DROP TABLE memos;

--source ../../../../../../include/mroonga/have_mroonga_deinit.inc
