# Bug report 2438
# within 中間要素の文字列長も考慮したテスト

Begin;
Initialize;

InitializeSession "TEST";
Command "create database TEST";
Command "create table T(ID int, F nvarchar(512), primary key(ID))";
Command "create fulltext index T_F on T(F) hint 'inverted=(indexing=dual, tokenizer=DUAL:JAP:ALL:2 @UNARSCID:1 @NORMRSCID:1)'";
Command "insert into T values (1, '熱定着可能な装置を提供すると同時に、高速度印刷を可能とする装置における各相の電力の偏りを少なくし、安価で信頼性の高い電子写真式印刷装置を実現する。')";

##### 検索語が包含関係にあるパターン #####
# すべてヒットしない

# 検索語3
Command "select count(*) from T where F contains within('定着' '高速' '高速' symmetric upper 100)";
Command "select count(*) from T where F contains within('定着' '高速度印刷' '速度' symmetric upper 100)";
Command "select count(*) from T where F contains within('定着' '高速度' '高速' symmetric upper 100)";
Command "select count(*) from T where F contains within('定着' '高速度' '速度' symmetric upper 100)";
Command "select count(*) from T where F contains within('定着' '速度印刷' '高速度' symmetric upper 100)";
Command "select count(*) from T where F contains within('定着' '高速度' '速度印刷' symmetric upper 100)";
# 検索語3 (前後逆)
Command "select count(*) from T where F contains within('定着' '高速' '高速' '高速' symmetric upper 100)";
Command "select count(*) from T where F contains within('定着' '速度' '高速度印刷' symmetric upper 100)";
Command "select count(*) from T where F contains within('定着' '高速' '高速度' symmetric upper 100)";
Command "select count(*) from T where F contains within('定着' '速度' '高速度' symmetric upper 100)";
Command "select count(*) from T where F contains within('定着' '高速度' '速度印刷' symmetric upper 100)";
Command "select count(*) from T where F contains within('定着' '速度印刷' '高速度' symmetric upper 100)";

# 検索語5
# 検索語の最後の2語が包含関係
Command "select count(*) from T where F contains within('定着' '装置' '同時' '高速' '高速' symmetric upper 100)";
Command "select count(*) from T where F contains within('定着' '装置' '同時' '高速度印刷' '速度' symmetric upper 100)";
Command "select count(*) from T where F contains within('定着' '装置' '同時' '高速度' '高速' symmetric upper 100)";
Command "select count(*) from T where F contains within('定着' '装置' '同時' '高速度' '速度' symmetric upper 100)";
Command "select count(*) from T where F contains within('定着' '装置' '同時' '速度印刷' '高速度' symmetric upper 100)";
Command "select count(*) from T where F contains within('定着' '装置' '同時' '高速度' '速度印刷' symmetric upper 100)";
# 前後逆
Command "select count(*) from T where F contains within('定着' '装置' '同時' '高速' '高速' '高速' symmetric upper 100)";
Command "select count(*) from T where F contains within('定着' '装置' '同時' '速度' '高速度印刷' symmetric upper 100)";
Command "select count(*) from T where F contains within('定着' '装置' '同時' '高速' '高速度' symmetric upper 100)";
Command "select count(*) from T where F contains within('定着' '装置' '同時' '速度' '高速度' symmetric upper 100)";
Command "select count(*) from T where F contains within('定着' '装置' '同時' '高速度' '速度印刷' symmetric upper 100)";
Command "select count(*) from T where F contains within('定着' '装置' '同時' '速度印刷' '高速度' symmetric upper 100)";

# 検索語5 
# 検索語の途中の2語が包含関係
Command "select count(*) from T where F contains within('定着' '装置' '高速' '高速' '電力' symmetric upper 100)";
Command "select count(*) from T where F contains within('定着' '装置' '高速度印刷' '速度' '電力' symmetric upper 100)";
Command "select count(*) from T where F contains within('定着' '装置' '高速度' '高速' '電力' symmetric upper 100)";
Command "select count(*) from T where F contains within('定着' '装置' '高速度' '速度' '電力' symmetric upper 100)";
Command "select count(*) from T where F contains within('定着' '装置' '速度印刷' '高速度' '電力' symmetric upper 100)";
Command "select count(*) from T where F contains within('定着' '装置' '高速度' '速度印刷' '電力' symmetric upper 100)";
# 前後逆
Command "select count(*) from T where F contains within('定着' '装置' '高速' '高速' '高速' '電力' symmetric upper 100)";
Command "select count(*) from T where F contains within('定着' '装置' '速度' '高速度印刷' '電力' symmetric upper 100)";
Command "select count(*) from T where F contains within('定着' '装置' '高速' '高速度' '電力' symmetric upper 100)";
Command "select count(*) from T where F contains within('定着' '装置' '速度' '高速度' '電力' symmetric upper 100)";
Command "select count(*) from T where F contains within('定着' '装置' '高速度' '速度印刷' '電力' symmetric upper 100)";
Command "select count(*) from T where F contains within('定着' '装置' '速度印刷' '高速度' '電力' symmetric upper 100)";

# 検索語10
# 最後の2語が包含関係
Command "select count(*) from T where F contains within('定着' '可能' '同時' '電力' '偏り' '安価' '信頼性' '電子' '印刷' '印刷' symmetric upper 100)";
Command "select count(*) from T where F contains within('定着' '可能' '同時' '電力' '偏り' '安価' '信頼性' '電子' '写真式印刷装置' '印刷' symmetric upper 100)";
Command "select count(*) from T where F contains within('定着' '可能' '同時' '電力' '偏り' '安価' '信頼性' '電子' '印刷装置' '印刷' symmetric upper 100)";
Command "select count(*) from T where F contains within('定着' '可能' '同時' '電力' '偏り' '安価' '信頼性' '電子' '写真式印刷' '印刷' symmetric upper 100)";
Command "select count(*) from T where F contains within('定着' '可能' '同時' '電力' '偏り' '安価' '信頼性' '電子' '印刷装置' '写真式印刷' symmetric upper 100)";
Command "select count(*) from T where F contains within('定着' '可能' '同時' '電力' '偏り' '安価' '信頼性' '電子' '写真式印刷' '印刷装置' symmetric upper 100)";
# 検索語10 (前後逆)
Command "select count(*) from T where F contains within('定着' '可能' '同時' '電力' '偏り' '安価' '信頼性' '電子' '印刷' '印刷' '印刷' symmetric upper 100)";
Command "select count(*) from T where F contains within('定着' '可能' '同時' '電力' '偏り' '安価' '信頼性' '電子' '印刷' '写真式印刷装置' symmetric upper 100)";
Command "select count(*) from T where F contains within('定着' '可能' '同時' '電力' '偏り' '安価' '信頼性' '電子' '印刷' '印刷装置' symmetric upper 100)";
Command "select count(*) from T where F contains within('定着' '可能' '同時' '電力' '偏り' '安価' '信頼性' '電子' '印刷' '写真式印刷' symmetric upper 100)";
Command "select count(*) from T where F contains within('定着' '可能' '同時' '電力' '偏り' '安価' '信頼性' '電子' '写真式印刷' '印刷装置' symmetric upper 100)";
Command "select count(*) from T where F contains within('定着' '可能' '同時' '電力' '偏り' '安価' '信頼性' '電子' '印刷装置' '写真式印刷' symmetric upper 100)";

# 検索語10
# 最初の2語が包含関係
Command "select count(*) from T where F contains within('定着' '定着' '可能' '同時' '電力' '偏り' '安価' '信頼性' '電子' '印刷' symmetric upper 100)";
Command "select count(*) from T where F contains within('熱定着可能' '定着' '可能' '同時' '電力' '偏り' '安価' '信頼性' '電子' '印刷' symmetric upper 100)";
Command "select count(*) from T where F contains within('熱定着' '熱' '同時' '電力' '偏り' '安価' '信頼性' '電子' '印刷' symmetric upper 100)";
Command "select count(*) from T where F contains within('熱定着' '定着' '同時' '電力' '偏り' '安価' '信頼性' '電子' '印刷' symmetric upper 100)";
Command "select count(*) from T where F contains within('定着可能' '熱定着' '同時' '電力' '偏り' '安価' '信頼性' '電子' '印刷' symmetric upper 100)";
Command "select count(*) from T where F contains within('熱定着' '定着可能' '同時' '電力' '偏り' '安価' '信頼性' '電子' '印刷' symmetric upper 100)";
# 検索語10 (前後逆)
Command "select count(*) from T where F contains within('定着' '定着' '定着' '可能' '同時' '電力' '偏り' '安価' '信頼性' '電子' '印刷' symmetric upper 100)";
Command "select count(*) from T where F contains within('定着' '熱定着可能' '可能' '同時' '電力' '偏り' '安価' '信頼性' '電子' '印刷' symmetric upper 100)";
Command "select count(*) from T where F contains within('熱' '熱定着' '同時' '電力' '偏り' '安価' '信頼性' '電子' '印刷' symmetric upper 100)";
Command "select count(*) from T where F contains within('定着' '熱定着' '同時' '電力' '偏り' '安価' '信頼性' '電子' '印刷' symmetric upper 100)";
Command "select count(*) from T where F contains within('熱定着' '定着可能' '同時' '電力' '偏り' '安価' '信頼性' '電子' '印刷' symmetric upper 100)";
Command "select count(*) from T where F contains within('定着可能' '熱定着' '同時' '電力' '偏り' '安価' '信頼性' '電子' '印刷' symmetric upper 100)";



##### 最後の検索語が途中にでてくるパターン #####
# 検索語3 (最初の検索語から最後の検索語まで27文字)
# ヒットする
Command "select count(*) from T where F contains within('定着' '高速' '装置' symmetric upper 28)";
Command "select count(*) from T where F contains within('定着' '高速' '装置' symmetric upper 27)";
Command "select count(*) from T where F contains within('定着' '高速' '装置' symmetric lower 26 upper 28)";
Command "select count(*) from T where F contains within('定着' '高速' '装置' symmetric lower 27 upper 28)";
Command "select count(*) from T where F contains within('定着' '高速' '装置' symmetric lower 26 upper 27)";
Command "select count(*) from T where F contains within('定着' '高速' '装置' symmetric lower 27 upper 27)";
# ヒットしない
Command "select count(*) from T where F contains within('定着' '高速' '装置' symmetric upper 26)";
Command "select count(*) from T where F contains within('定着' '高速' '装置' symmetric lower 28 upper 28)";
Command "select count(*) from T where F contains within('定着' '高速' '装置' symmetric lower 26 upper 26)";
Command "select count(*) from T where F contains within('定着' '高速' '装置' symmetric lower 28 upper 26)";

# 検索語5 (最初の検索語から最後の検索語まで27文字)
# ヒットする
Command "select count(*) from T where F contains within('定着' '同時' '高速' '印刷' '装置' symmetric upper 28)";
Command "select count(*) from T where F contains within('定着' '同時' '高速' '印刷' '装置' symmetric upper 27)";
Command "select count(*) from T where F contains within('定着' '同時' '高速' '印刷' '装置' symmetric lower 26 upper 28)";
Command "select count(*) from T where F contains within('定着' '同時' '高速' '印刷' '装置' symmetric lower 27 upper 28)";
Command "select count(*) from T where F contains within('定着' '同時' '高速' '印刷' '装置' symmetric lower 26 upper 27)";
Command "select count(*) from T where F contains within('定着' '同時' '高速' '印刷' '装置' symmetric lower 27 upper 27)";
# ヒットしない
Command "select count(*) from T where F contains within('定着' '同時' '高速' '印刷' '装置' symmetric upper 26)";
Command "select count(*) from T where F contains within('定着' '同時' '高速' '印刷' '装置' symmetric lower 28 upper 28)";
Command "select count(*) from T where F contains within('定着' '同時' '高速' '印刷' '装置' symmetric lower 26 upper 26)";
Command "select count(*) from T where F contains within('定着' '同時' '高速' '印刷' '装置' symmetric lower 28 upper 26)";

# 検索語10(最初の検索後から最後の検索語まで63文字)
# ヒットする
Command "select count(*) from T where F contains within('定着' '高速度' '印刷' '電力' '偏り' '安価' '信頼性' '電子' '写真' '装置' symmetric upper 64)";
Command "select count(*) from T where F contains within('定着' '高速度' '印刷' '電力' '偏り' '安価' '信頼性' '電子' '写真' '装置' symmetric upper 63)";
Command "select count(*) from T where F contains within('定着' '高速度' '印刷' '電力' '偏り' '安価' '信頼性' '電子' '写真' '装置' symmetric lower 62 upper 64)";
Command "select count(*) from T where F contains within('定着' '高速度' '印刷' '電力' '偏り' '安価' '信頼性' '電子' '写真' '装置' symmetric lower 63 upper 64)";
Command "select count(*) from T where F contains within('定着' '高速度' '印刷' '電力' '偏り' '安価' '信頼性' '電子' '写真' '装置' symmetric lower 62 upper 63)";
Command "select count(*) from T where F contains within('定着' '高速度' '印刷' '電力' '偏り' '安価' '信頼性' '電子' '写真' '装置' symmetric lower 63 upper 63)";
# ヒットしない
Command "select count(*) from T where F contains within('定着' '高速度' '印刷' '電力' '偏り' '安価' '信頼性' '電子' '写真' '装置' symmetric upper 62)";
Command "select count(*) from T where F contains within('定着' '高速度' '印刷' '電力' '偏り' '安価' '信頼性' '電子' '写真' '装置' symmetric lower 64 upper 64)";
Command "select count(*) from T where F contains within('定着' '高速度' '印刷' '電力' '偏り' '安価' '信頼性' '電子' '写真' '装置' symmetric lower 62 upper 62)";
Command "select count(*) from T where F contains within('定着' '高速度' '印刷' '電力' '偏り' '安価' '信頼性' '電子' '写真' '装置' symmetric lower 64 upper 62)";

TerminateSession;
Terminate;
End;

