# 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/not_embedded.inc
--source ../../../../../include/mroonga/have_mroonga.inc

CREATE TABLE terms (
  name VARCHAR(64) PRIMARY KEY
) DEFAULT CHARSET=utf8mb4
  COMMENT='default_tokenizer "TokenBigram"';

CREATE TABLE bugs (
  id INT UNSIGNED PRIMARY KEY,
  title TEXT,
  FULLTEXT INDEX (title) COMMENT 'table "terms"'
) DEFAULT CHARSET=utf8mb4;

INSERT INTO bugs (id, title) VALUES (1, "Mroonga can't build with MySQL X.Y.Z");

--sorted_result
SELECT * FROM terms ORDER BY name;

SELECT *, MATCH (title) AGAINST ("+MySQL" IN BOOLEAN MODE) AS score
       FROM bugs
       WHERE MATCH (title) AGAINST ("+MySQL" IN BOOLEAN MODE);

DROP TABLE bugs;
DROP TABLE terms;

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