次の表とストアドプロシージャをループ付きのmysqlに作成しました。部分的にうまくいくようです。部分的に正しい結果を生成する完全なテキスト検索用のストアドプロシージャ
DROP table if EXISTS x;
DROP table if exists y;
DROP TABLE if EXISTS z;
CREATE TABLE x (`code` VARCHAR(10) not null primary key,
description text, fulltext key(description));
INSERT INTO x
VALUES(2111,'rice, husked'),
('0113','rice, paddy'),
('0124','fish, fresh'),
(2225,'beef meat'),
('0114','bananas'),
('0115','mango');
CREATE TABLE y (section text not null, `code` text);
INSERT INTO y
values('food', 'rice local'),
('food', 'rice imported'),
('food', 'beer'),
('food', 'banana');
create table z (section text not null, `code` text, cpc VARCHAR(10)
NULL);
drop procedure if exists fmatch;
delimiter //
create procedure fmatch()
language sql
deterministic
sql security definer
begin
declare v_code VARCHAR(10);
declare v_description text;
declare v_finished int;
declare c cursor for select * from x ;
declare continue handler for not found set v_finished=1;
delete from z;
open c;
c_loop: loop
fetch c into v_code,v_description;
if v_finished then
leave c_loop;
end if;
insert into z
select y.section, y.`code`, v_code
from y where match (y.`code`) against (v_description in boolean mode);
end loop c_loop;
close c;
select * from z;
end//
delimiter ;
call fmatch();
として、ここで生成される結果:私が間違っているあなたのアドバイスを求めている
section code cpc
food banana 0114
food beer null
food rice local 0113
food rice imported 0113
:代わりに
section code cpc
food rice local 2111
food rice imported 2111
food rice local 0113
food rice imported 0113
は、私が結果として得られたテーブルが欲しいです。
なぜ出力でなければならないと思いますか? FTSに多くのデータを投函して機能させる必要があります。あなたはそれを訓練する。ストップワードで何千もの行を考える。 – Drew
@Drew、たとえ小さなデータセットであっても、正しいマッピングを提供する必要があります。これは私が試しているテストケースにすぎないことに注意してください。ループ構造が間違っていますか? –
FTSは、非FTSのように、担当するAbdullahではありません。それは、ファジーなエンジンに渡して最良の選択をしています。マニュアルに明記されている量が付属しています。だから、FTSと非FTSを混同しないでください – Drew