mirror of
https://github.com/MariaDB/server.git
synced 2026-01-06 05:22:24 +03:00
merged
This commit is contained in:
@@ -119,7 +119,8 @@ a b
|
||||
MySQL has now support for full-text search
|
||||
select * from t1 where MATCH a,b AGAINST ('"text i"' IN BOOLEAN MODE);
|
||||
a b
|
||||
Full-text indexes are called collections
|
||||
select * from t1 where MATCH a,b AGAINST ('"xt indexes"' IN BOOLEAN MODE);
|
||||
a b
|
||||
select * from t1 where MATCH a AGAINST ("search" IN BOOLEAN MODE);
|
||||
a b
|
||||
Full-text search in MySQL implements vector space model
|
||||
@@ -190,6 +191,12 @@ ticket inhalt
|
||||
select * from t2 having MATCH inhalt AGAINST ('foobar');
|
||||
ticket inhalt
|
||||
3 foobar
|
||||
CREATE TABLE t3 (t int(11),i text,fulltext tix (t,i));
|
||||
ERROR HY000: Column 't' cannot be part of FULLTEXT index
|
||||
CREATE TABLE t3 (t int(11),i text,
|
||||
j varchar(200) CHARACTER SET latin2,
|
||||
fulltext tix (i,j));
|
||||
ERROR HY000: Column 'j' cannot be part of FULLTEXT index
|
||||
CREATE TABLE t3 (
|
||||
ticket int(11),
|
||||
inhalt text,
|
||||
@@ -272,3 +279,24 @@ select * from t1 join t2 using(`t1_id`) where match (t1.name, t2.name) against('
|
||||
t1_id name t2_id t1_id name
|
||||
1 data1 1 1 xxfoo
|
||||
drop table t1,t2;
|
||||
SET NAMES latin1;
|
||||
CREATE TABLE t1 (t text character set utf8 not null, fulltext(t));
|
||||
INSERT t1 VALUES ('Mit freundlichem Gr<47><72>'), ('aus Osnabr<62>ck');
|
||||
SET NAMES koi8r;
|
||||
INSERT t1 VALUES ("<22><><EFBFBD> <20><> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"),("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD>!"),
|
||||
("<22><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD>!"),("<22> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>!");
|
||||
SELECT t, charset(t) FROM t1 WHERE MATCH t AGAINST ('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||||
t charset(t)
|
||||
<EFBFBD><EFBFBD><EFBFBD> <20><> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> utf8
|
||||
SELECT t, charset(t) FROM t1 WHERE MATCH t AGAINST ('<27><><EFBFBD>*' IN BOOLEAN MODE);
|
||||
t charset(t)
|
||||
<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>! utf8
|
||||
SELECT * FROM t1 WHERE MATCH t AGAINST ('<27><><EFBFBD>' IN BOOLEAN MODE);
|
||||
t
|
||||
SELECT t, charset(t) FROM t1 WHERE MATCH t AGAINST ('Osnabr<62>ck');
|
||||
t charset(t)
|
||||
SET NAMES latin1;
|
||||
SELECT t, charset(t) FROM t1 WHERE MATCH t AGAINST ('Osnabr<62>ck');
|
||||
t charset(t)
|
||||
aus Osnabr<62>ck utf8
|
||||
DROP TABLE t1;
|
||||
|
||||
@@ -103,4 +103,106 @@ count(*)
|
||||
select count(*) from t1 where match a against ('aaazzz' in boolean mode);
|
||||
count(*)
|
||||
262
|
||||
DROP TABLE IF EXISTS t1;
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (
|
||||
i int(10) unsigned not null auto_increment primary key,
|
||||
a varchar(255) not null,
|
||||
FULLTEXT KEY (a)
|
||||
) TYPE=MyISAM;
|
||||
select count(*) from t1 where match a against ('aaaxxx');
|
||||
count(*)
|
||||
260
|
||||
select count(*) from t1 where match a against ('aaayyy');
|
||||
count(*)
|
||||
250
|
||||
select count(*) from t1 where match a against ('aaazzz');
|
||||
count(*)
|
||||
255
|
||||
select count(*) from t1 where match a against ('aaaxxx' in boolean mode);
|
||||
count(*)
|
||||
260
|
||||
select count(*) from t1 where match a against ('aaayyy' in boolean mode);
|
||||
count(*)
|
||||
250
|
||||
select count(*) from t1 where match a against ('aaazzz' in boolean mode);
|
||||
count(*)
|
||||
255
|
||||
select count(*) from t1 where match a against ('aaaxxx aaayyy aaazzz');
|
||||
count(*)
|
||||
765
|
||||
select count(*) from t1 where match a against ('aaaxxx aaayyy aaazzz' in boolean mode);
|
||||
count(*)
|
||||
765
|
||||
select count(*) from t1 where match a against ('aaax*' in boolean mode);
|
||||
count(*)
|
||||
260
|
||||
select count(*) from t1 where match a against ('aaay*' in boolean mode);
|
||||
count(*)
|
||||
250
|
||||
select count(*) from t1 where match a against ('aaa*' in boolean mode);
|
||||
count(*)
|
||||
765
|
||||
insert t1 (a) values ('aaaxxx'),('aaayyy');
|
||||
insert t1 (a) values ('aaazzz'),('aaazzz'),('aaazzz'),('aaazzz'),('aaazzz');
|
||||
select count(*) from t1 where match a against ('aaaxxx');
|
||||
count(*)
|
||||
261
|
||||
select count(*) from t1 where match a against ('aaayyy');
|
||||
count(*)
|
||||
251
|
||||
select count(*) from t1 where match a against ('aaazzz');
|
||||
count(*)
|
||||
260
|
||||
insert t1 (a) values ('aaaxxx 000000');
|
||||
select count(*) from t1 where match a against ('000000');
|
||||
count(*)
|
||||
1
|
||||
delete from t1 where match a against ('000000');
|
||||
select count(*) from t1 where match a against ('000000');
|
||||
count(*)
|
||||
0
|
||||
select count(*) from t1 where match a against ('aaaxxx');
|
||||
count(*)
|
||||
261
|
||||
delete from t1 where match a against ('aaazzz');
|
||||
select count(*) from t1 where match a against ('aaaxxx' in boolean mode);
|
||||
count(*)
|
||||
261
|
||||
select count(*) from t1 where match a against ('aaayyy' in boolean mode);
|
||||
count(*)
|
||||
251
|
||||
select count(*) from t1 where match a against ('aaazzz' in boolean mode);
|
||||
count(*)
|
||||
0
|
||||
select count(*) from t1 where a = 'aaaxxx';
|
||||
count(*)
|
||||
261
|
||||
select count(*) from t1 where a = 'aaayyy';
|
||||
count(*)
|
||||
251
|
||||
select count(*) from t1 where a = 'aaazzz';
|
||||
count(*)
|
||||
0
|
||||
insert t1 (a) values ('aaaxxx 000000');
|
||||
select count(*) from t1 where match a against ('000000');
|
||||
count(*)
|
||||
1
|
||||
update t1 set a='aaazzz' where match a against ('000000');
|
||||
select count(*) from t1 where match a against ('aaaxxx' in boolean mode);
|
||||
count(*)
|
||||
261
|
||||
select count(*) from t1 where match a against ('aaazzz' in boolean mode);
|
||||
count(*)
|
||||
1
|
||||
update t1 set a='aaazzz' where a = 'aaaxxx';
|
||||
update t1 set a='aaaxxx' where a = 'aaayyy';
|
||||
select count(*) from t1 where match a against ('aaaxxx' in boolean mode);
|
||||
count(*)
|
||||
251
|
||||
select count(*) from t1 where match a against ('aaayyy' in boolean mode);
|
||||
count(*)
|
||||
0
|
||||
select count(*) from t1 where match a against ('aaazzz' in boolean mode);
|
||||
count(*)
|
||||
262
|
||||
drop table t1;
|
||||
|
||||
@@ -58,6 +58,7 @@ select * from t1 where MATCH a,b AGAINST ('"text search" "now support"' IN BOOL
|
||||
select * from t1 where MATCH a,b AGAINST ('"text search" -"now support"' IN BOOLEAN MODE);
|
||||
select * from t1 where MATCH a,b AGAINST ('"text search" +"now support"' IN BOOLEAN MODE);
|
||||
select * from t1 where MATCH a,b AGAINST ('"text i"' IN BOOLEAN MODE);
|
||||
select * from t1 where MATCH a,b AGAINST ('"xt indexes"' IN BOOLEAN MODE);
|
||||
|
||||
# boolean w/o index:
|
||||
|
||||
@@ -129,6 +130,13 @@ select * from t2 having MATCH inhalt AGAINST ('foobar');
|
||||
# check of fulltext errors
|
||||
#
|
||||
|
||||
--error 1279
|
||||
CREATE TABLE t3 (t int(11),i text,fulltext tix (t,i));
|
||||
--error 1279
|
||||
CREATE TABLE t3 (t int(11),i text,
|
||||
j varchar(200) CHARACTER SET latin2,
|
||||
fulltext tix (i,j));
|
||||
|
||||
CREATE TABLE t3 (
|
||||
ticket int(11),
|
||||
inhalt text,
|
||||
@@ -218,3 +226,21 @@ insert into t2 values (2, 1, 'xxbar');
|
||||
insert into t2 values (3, 1, 'xxbuz');
|
||||
select * from t1 join t2 using(`t1_id`) where match (t1.name, t2.name) against('xxfoo' in boolean mode);
|
||||
drop table t1,t2;
|
||||
|
||||
#
|
||||
# UTF8
|
||||
#
|
||||
SET NAMES latin1;
|
||||
CREATE TABLE t1 (t text character set utf8 not null, fulltext(t));
|
||||
INSERT t1 VALUES ('Mit freundlichem Gr<47><72>'), ('aus Osnabr<62>ck');
|
||||
SET NAMES koi8r;
|
||||
INSERT t1 VALUES ("<22><><EFBFBD> <20><> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"),("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD>!"),
|
||||
("<22><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD>!"),("<22> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>!");
|
||||
SELECT t, charset(t) FROM t1 WHERE MATCH t AGAINST ('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
||||
SELECT t, charset(t) FROM t1 WHERE MATCH t AGAINST ('<27><><EFBFBD>*' IN BOOLEAN MODE);
|
||||
SELECT * FROM t1 WHERE MATCH t AGAINST ('<27><><EFBFBD>' IN BOOLEAN MODE);
|
||||
SELECT t, charset(t) FROM t1 WHERE MATCH t AGAINST ('Osnabr<62>ck');
|
||||
SET NAMES latin1;
|
||||
SELECT t, charset(t) FROM t1 WHERE MATCH t AGAINST ('Osnabr<62>ck');
|
||||
DROP TABLE t1;
|
||||
|
||||
|
||||
@@ -94,5 +94,83 @@ select count(*) from t1 where match a against ('aaaxxx' in boolean mode);
|
||||
select count(*) from t1 where match a against ('aaayyy' in boolean mode);
|
||||
select count(*) from t1 where match a against ('aaazzz' in boolean mode);
|
||||
|
||||
DROP TABLE IF EXISTS t1;
|
||||
drop table t1;
|
||||
|
||||
CREATE TABLE t1 (
|
||||
i int(10) unsigned not null auto_increment primary key,
|
||||
a varchar(255) not null,
|
||||
FULLTEXT KEY (a)
|
||||
) TYPE=MyISAM;
|
||||
|
||||
# two-level entry, second-level tree with depth 2
|
||||
--disable_query_log
|
||||
let $1=260;
|
||||
while ($1)
|
||||
{
|
||||
eval insert t1 (a) values ('aaaxxx');
|
||||
dec $1;
|
||||
}
|
||||
let $1=255;
|
||||
while ($1)
|
||||
{
|
||||
eval insert t1 (a) values ('aaazzz');
|
||||
dec $1;
|
||||
}
|
||||
let $1=250;
|
||||
while ($1)
|
||||
{
|
||||
eval insert t1 (a) values ('aaayyy');
|
||||
dec $1;
|
||||
}
|
||||
--enable_query_log
|
||||
|
||||
select count(*) from t1 where match a against ('aaaxxx');
|
||||
select count(*) from t1 where match a against ('aaayyy');
|
||||
select count(*) from t1 where match a against ('aaazzz');
|
||||
select count(*) from t1 where match a against ('aaaxxx' in boolean mode);
|
||||
select count(*) from t1 where match a against ('aaayyy' in boolean mode);
|
||||
select count(*) from t1 where match a against ('aaazzz' in boolean mode);
|
||||
select count(*) from t1 where match a against ('aaaxxx aaayyy aaazzz');
|
||||
select count(*) from t1 where match a against ('aaaxxx aaayyy aaazzz' in boolean mode);
|
||||
|
||||
select count(*) from t1 where match a against ('aaax*' in boolean mode);
|
||||
select count(*) from t1 where match a against ('aaay*' in boolean mode);
|
||||
select count(*) from t1 where match a against ('aaa*' in boolean mode);
|
||||
|
||||
# mi_write:
|
||||
|
||||
insert t1 (a) values ('aaaxxx'),('aaayyy');
|
||||
insert t1 (a) values ('aaazzz'),('aaazzz'),('aaazzz'),('aaazzz'),('aaazzz');
|
||||
select count(*) from t1 where match a against ('aaaxxx');
|
||||
select count(*) from t1 where match a against ('aaayyy');
|
||||
select count(*) from t1 where match a against ('aaazzz');
|
||||
|
||||
# mi_delete
|
||||
insert t1 (a) values ('aaaxxx 000000');
|
||||
select count(*) from t1 where match a against ('000000');
|
||||
delete from t1 where match a against ('000000');
|
||||
select count(*) from t1 where match a against ('000000');
|
||||
select count(*) from t1 where match a against ('aaaxxx');
|
||||
delete from t1 where match a against ('aaazzz');
|
||||
select count(*) from t1 where match a against ('aaaxxx' in boolean mode);
|
||||
select count(*) from t1 where match a against ('aaayyy' in boolean mode);
|
||||
select count(*) from t1 where match a against ('aaazzz' in boolean mode);
|
||||
# double-check without index
|
||||
select count(*) from t1 where a = 'aaaxxx';
|
||||
select count(*) from t1 where a = 'aaayyy';
|
||||
select count(*) from t1 where a = 'aaazzz';
|
||||
|
||||
# update
|
||||
insert t1 (a) values ('aaaxxx 000000');
|
||||
select count(*) from t1 where match a against ('000000');
|
||||
update t1 set a='aaazzz' where match a against ('000000');
|
||||
select count(*) from t1 where match a against ('aaaxxx' in boolean mode);
|
||||
select count(*) from t1 where match a against ('aaazzz' in boolean mode);
|
||||
update t1 set a='aaazzz' where a = 'aaaxxx';
|
||||
update t1 set a='aaaxxx' where a = 'aaayyy';
|
||||
select count(*) from t1 where match a against ('aaaxxx' in boolean mode);
|
||||
select count(*) from t1 where match a against ('aaayyy' in boolean mode);
|
||||
select count(*) from t1 where match a against ('aaazzz' in boolean mode);
|
||||
|
||||
drop table t1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user