| 1 |
## manipulate of fulltext indexes on document |
| 2 |
|
| 3 |
--source include/xplugin_preamble.inc |
| 4 |
--source include/xplugin_create_user.inc |
| 5 |
|
| 6 |
## Test starts here |
| 7 |
--let $xtest_file= $MYSQL_TMP_DIR/admin_create_index_fulltext.xpl |
| 8 |
--write_file $xtest_file |
| 9 |
-->quiet |
| 10 |
|
| 11 |
## Test data |
| 12 |
|
| 13 |
|
| 14 |
-->macro Insert %COLL% %VALUE% %ERROR% |
| 15 |
Mysqlx.Crud.Insert { |
| 16 |
collection { |
| 17 |
name: "%COLL%" |
| 18 |
schema: "xtest" |
| 19 |
} |
| 20 |
data_model: DOCUMENT |
| 21 |
row { |
| 22 |
field { |
| 23 |
type: LITERAL |
| 24 |
literal { |
| 25 |
type: V_STRING |
| 26 |
v_string { |
| 27 |
value: %VALUE% |
| 28 |
} |
| 29 |
} |
| 30 |
} |
| 31 |
} |
| 32 |
} |
| 33 |
-->expecterror %ERROR% |
| 34 |
-->recvresult |
| 35 |
-->endmacro |
| 36 |
|
| 37 |
-->macro Show %COLL% |
| 38 |
-->echo ### Columns of %COLL% |
| 39 |
-->stmtsql show columns from xtest.%COLL% |
| 40 |
-->recvresult |
| 41 |
-->echo ### Indexes of %COLL% |
| 42 |
-->stmtsql show index from xtest.%COLL% |
| 43 |
-->recvresult |
| 44 |
-->echo ############################ |
| 45 |
-->endmacro |
| 46 |
|
| 47 |
-->title =Create collection fulltext1 |
| 48 |
-->stmtadmin create_collection {"schema":"xtest", "name":"fulltext1"} |
| 49 |
-->recvresult |
| 50 |
|
| 51 |
|
| 52 |
-->title =check required status var updated |
| 53 |
-->sql |
| 54 |
SHOW STATUS like 'Mysqlx_stmt_create_collection_index%'; |
| 55 |
SHOW STATUS like 'Mysqlx_stmt_drop_collection_index%'; |
| 56 |
SHOW STATUS LIKE 'Mysqlx_stmt_execute_mysqlx'; |
| 57 |
-->endsql |
| 58 |
|
| 59 |
|
| 60 |
-->title =Create entire document fulltext index and drop it |
| 61 |
-->stmtadmin create_collection_index {"schema":"xtest", "collection":"fulltext1", "type":"fulltext", "name":"one", "unique":false, "fields":{"field":"$", "type":"fulltext", "required":true}} |
| 62 |
-->recvresult |
| 63 |
-->callmacro Show fulltext1 |
| 64 |
-->stmtadmin drop_collection_index {"schema":"xtest", "collection":"fulltext1", "name":"one"} |
| 65 |
-->recvresult |
| 66 |
-->callmacro Show fulltext1 |
| 67 |
|
| 68 |
-->sql |
| 69 |
SHOW STATUS like 'Mysqlx_stmt_create_collection_index%'; |
| 70 |
SHOW STATUS like 'Mysqlx_stmt_drop_collection_index%'; |
| 71 |
SHOW STATUS LIKE 'Mysqlx_stmt_execute_mysqlx'; |
| 72 |
-->endsql |
| 73 |
|
| 74 |
|
| 75 |
-->title =Create fulltext index (without constraint.type) and drop it |
| 76 |
-->stmtadmin create_collection_index {"schema":"xtest", "collection":"fulltext1", "type":"fulltext", "name":"one", "unique":false, "fields":{"field":"$.first", "required":true}} |
| 77 |
-->recvresult |
| 78 |
-->callmacro Show fulltext1 |
| 79 |
-->stmtadmin drop_collection_index {"schema":"xtest", "collection":"fulltext1", "name":"one"} |
| 80 |
-->recvresult |
| 81 |
-->callmacro Show fulltext1 |
| 82 |
|
| 83 |
-->title =Create two fulltext indexes on the same member and drop one |
| 84 |
-->stmtadmin create_collection_index {"schema":"xtest", "collection":"fulltext1", "type":"fulltext", "name":"one", "unique":false, "fields":{"field":"$.first", "type":"fulltext", "required":true}} |
| 85 |
-->recvresult |
| 86 |
-->stmtadmin create_collection_index {"schema":"xtest", "collection":"fulltext1", "type":"fulltext", "name":"two", "unique":false, "fields":{"field":"$.first", "type":"fulltext", "required":true}} |
| 87 |
-->recvresult |
| 88 |
-->callmacro Show fulltext1 |
| 89 |
|
| 90 |
-->title =Drop fulltext index on $.first |
| 91 |
-->stmtadmin drop_collection_index {"schema":"xtest", "collection":"fulltext1", "name":"one"} |
| 92 |
-->recvresult |
| 93 |
-->callmacro Show fulltext1 |
| 94 |
|
| 95 |
-->title =Create fulltext index on two memebers |
| 96 |
-->stmtadmin create_collection_index {"schema":"xtest", "collection":"fulltext1", "type":"fulltext", "name":"three", "unique":false, "fields":[{"field":"$.first", "type":"fulltext", "required":true},{"field":"$.second", "type":"fulltext", "required":true}]} |
| 97 |
-->recvresult |
| 98 |
-->callmacro Show fulltext1 |
| 99 |
|
| 100 |
-->title =Create fulltext index on not requiered member |
| 101 |
-->stmtadmin create_collection_index {"schema":"xtest", "collection":"fulltext1", "type":"fulltext", "name":"four", "unique":false, "fields":{"field":"$.second", "type":"fulltext", "required":false}} |
| 102 |
-->recvresult |
| 103 |
-->callmacro Show fulltext1 |
| 104 |
|
| 105 |
-->title =Create fulltext index with parser |
| 106 |
-->stmtadmin create_collection_index {"schema":"xtest", "collection":"fulltext1", "type":"fulltext", "name":"five", "unique":false, "with_parser":"ngram", "fields":{"field":"$.third", "type":"fulltext", "required":false}} |
| 107 |
-->recvresult |
| 108 |
-->callmacro Show fulltext1 |
| 109 |
|
| 110 |
|
| 111 |
-->title =Is collection with fulltext index still collection? |
| 112 |
-->stmtadmin list_objects {"schema":"xtest"} |
| 113 |
-->recvresult |
| 114 |
|
| 115 |
-->title =Drop collection fulltext1 |
| 116 |
-->stmtadmin drop_collection {"schema":"xtest", "name":"fulltext1"} |
| 117 |
-->recvresult |
| 118 |
|
| 119 |
-->title =Create collection fulltext1 |
| 120 |
-->stmtadmin create_collection {"schema":"xtest", "name":"fulltext1"} |
| 121 |
-->recvresult |
| 122 |
-->title =Create fulltext index with FULLTEXT instead of fulltext |
| 123 |
-->stmtadmin create_collection_index {"schema":"xtest", "collection":"fulltext1", "type":"FULLTEXT", "name":"four", "unique":false, "fields":{"field":"$.second", "type":"FULLTEXT", "required":true}} |
| 124 |
-->recvresult |
| 125 |
-->title =Verify "NOT NULL" for generated column |
| 126 |
-->callmacro Show fulltext1 |
| 127 |
-->title =Check generated column can be dropped |
| 128 |
-->stmtsql ALTER TABLE xtest.fulltext1 DROP COLUMN `$ix_ft_r_350BEBA0BA8F7BA4E147A3E652BE04A3B53B4479`; |
| 129 |
-->recvresult |
| 130 |
-->title =Create fulltext index with FULLTEXT nested doc |
| 131 |
-->stmtadmin create_collection_index {"schema":"xtest", "collection":"fulltext1", "type":"FULLTEXT", "name":"five", "unique":false, "fields":{"field":"$.b[1].c", "type":"FULLTEXT", "required":true}} |
| 132 |
-->recvresult |
| 133 |
-->stmtadmin disable_notices {"notice":"warnings"} |
| 134 |
-->recvresult |
| 135 |
-->title =Drop collection fulltext1 |
| 136 |
-->stmtadmin drop_collection {"schema":"xtest", "name":"fulltext1"} |
| 137 |
-->recvresult |
| 138 |
|
| 139 |
|
| 140 |
-->title =Create collection fulltext2 |
| 141 |
-->stmtadmin create_collection {"schema":"xtest", "name":"fulltext2"} |
| 142 |
-->recvresult |
| 143 |
|
| 144 |
-->title =Try to create unique fulltext index |
| 145 |
-->stmtadmin create_collection_index {"schema":"xtest", "collection":"fulltext2", "type":"fulltext", "name":"five", "unique":true, "fields":{"field":"$.first", "type":"fulltext", "required":true}} |
| 146 |
-->expecterror ER_X_CMD_ARGUMENT_VALUE |
| 147 |
-->recvresult |
| 148 |
|
| 149 |
-->title =Insert not-text values to collection with fulltext index |
| 150 |
-->stmtadmin create_collection_index {"schema":"xtest", "collection":"fulltext2", "type":"fulltext", "name":"six", "unique":false, "fields":{"field":"$.first", "type":"fulltext", "required":false}} |
| 151 |
-->recvresult |
| 152 |
-->callmacro Insert fulltext2 '{"_id": "one", "first":30}' ER_SUCCESS |
| 153 |
-->callmacro Insert fulltext2 '{"_id": "three", "first":{"second":42}}' ER_SUCCESS |
| 154 |
-->callmacro Insert fulltext2 '{"_id": "two", "first":null}' ER_SUCCESS |
| 155 |
-->callmacro Insert fulltext2 '{"_id": "five", "second":30}' ER_SUCCESS |
| 156 |
|
| 157 |
-->title =Try to create fulltext index on missing member |
| 158 |
-->stmtadmin create_collection_index {"schema":"xtest", "collection":"fulltext2", "type":"fulltext", "name":"seven", "unique":false, "fields":{"field":"$.first", "type":"fulltext", "required":true}} |
| 159 |
-->expecterror ER_X_DOC_REQUIRED_FIELD_MISSING |
| 160 |
-->recvresult |
| 161 |
|
| 162 |
|
| 163 |
-->title =Try to create fulltext index with unknown parser |
| 164 |
-->stmtadmin create_collection_index {"schema":"xtest", "collection":"fulltext2", "type":"fulltext", "name":"eight", "unique":false, "with_parser": "blablabla", "fields":{"field":"$.first", "type":"fulltext", "required":false}} |
| 165 |
-->expecterror ER_FUNCTION_NOT_DEFINED |
| 166 |
-->recvresult |
| 167 |
|
| 168 |
-->title =Try to create 'regular' index with parser |
| 169 |
-->stmtadmin create_collection_index {"schema":"xtest", "collection":"fulltext2", "type":"index", "name":"nine", "unique":false, "with_parser": "ngram", "fields":{"field":"$.first", "type":"fulltext", "required":false}} |
| 170 |
-->expecterror ER_X_CMD_ARGUMENT_VALUE |
| 171 |
-->recvresult |
| 172 |
EOF |
| 173 |
|
| 174 |
CREATE SCHEMA xtest DEFAULT CHARSET 'utf8mb4'; |
| 175 |
|
| 176 |
--exec $MYSQLXTEST -ux_root --password='' --file=$xtest_file 2>&1 |
| 177 |
|
| 178 |
## Cleanup |
| 179 |
--source ../include/xplugin_cleanup.inc |
| 180 |
|