Manticore Search 对表只有单层层级结构。
与其他数据库管理系统不同,Manticore 中没有将表分组到数据库中的概念。然而,为了与 SQL 方言的互操作性,Manticore 接受 SHOW DATABASES 语句,但该语句不会返回任何结果。
通用语法:
SHOW TABLES [ LIKE pattern ]
SHOW TABLES 语句列出所有当前活动的表及其类型。现有的表类型有 local、distributed、rt、percolate 和 template。
$client->nodes()->table();
utilsApi.sql('SHOW TABLES')
await utilsApi.sql('SHOW TABLES')
res = await utilsApi.sql('SHOW TABLES');
utilsApi.sql("SHOW TABLES", true)
utilsApi.Sql("SHOW TABLES", true)
utils_api.sql("SHOW TABLES", Some(true)).await
+----------+-------------+
| Index | Type |
+----------+-------------+
| dist | distributed |
| plain | local |
| pq | percolate |
| rt | rt |
| template | template |
+----------+-------------+
5 rows in set (0.00 sec)
Array
(
[dist1] => distributed
[rt] => rt
[products] => rt
)
{u'columns': [{u'Index': {u'type': u'string'}},
{u'Type': {u'type': u'string'}}],
u'data': [{u'Index': u'dist1', u'Type': u'distributed'},
{u'Index': u'rt', u'Type': u'rt'},
{u'Index': u'products', u'Type': u'rt'}],
u'error': u'',
u'total': 0,
u'warning': u''}
{u'columns': [{u'Index': {u'type': u'string'}},
{u'Type': {u'type': u'string'}}],
u'data': [{u'Index': u'dist1', u'Type': u'distributed'},
{u'Index': u'rt', u'Type': u'rt'},
{u'Index': u'products', u'Type': u'rt'}],
u'error': u'',
u'total': 0,
u'warning': u''}
{"columns":[{"Index":{"type":"string"}},{"Type":{"type":"string"}}],"data":[{"Index":"products","Type":"rt"}],"total":0,"error":"","warning":""}
{columns=[{Index={type=string}}, {Type={type=string}}], data=[{Index=products, Type=rt}], total=0, error=, warning=}
{columns=[{Index={type=string}}, {Type={type=string}}], data=[{Index=products, Type=rt}], total=0, error="", warning=""}
{columns=[{Index={type=string}}, {Type={type=string}}], data=[{Index=products, Type=rt}], total=0, error="", warning=""}
$client->nodes()->table(['body'=>['pattern'=>'pro%']]);
utilsApi.sql('SHOW TABLES LIKE \'pro%\'');
await utilsApi.sql('SHOW TABLES LIKE \'pro%\'');
utilsApi.sql('SHOW TABLES LIKE \'pro%\'')
utilsApi.sql("SHOW TABLES LIKE 'pro%'", true)
utilsApi.Sql("SHOW TABLES LIKE 'pro%'", true)
utils_api.sql("SHOW TABLES LIKE 'pro%'", Some(true)).await
+----------+-------------+
| Index | Type |
+----------+-------------+
| products | distributed |
+----------+-------------+
1 row in set (0.00 sec)
Array
(
[products] => distributed
)
{u'columns': [{u'Index': {u'type': u'string'}},
{u'Type': {u'type': u'string'}}],
u'data': [{u'Index': u'products', u'Type': u'rt'}],
u'error': u'',
u'total': 0,
u'warning': u''}
{u'columns': [{u'Index': {u'type': u'string'}},
{u'Type': {u'type': u'string'}}],
u'data': [{u'Index': u'products', u'Type': u'rt'}],
u'error': u'',
u'total': 0,
u'warning': u''}
{"columns":[{"Index":{"type":"string"}},{"Type":{"type":"string"}}],"data":[{"Index":"products","Type":"rt"}],"total":0,"error":"","warning":""}
{columns=[{Index={type=string}}, {Type={type=string}}], data=[{Index=products, Type=rt}], total=0, error=, warning=}
{columns=[{Index={type=string}}, {Type={type=string}}], data=[{Index=products, Type=rt}], total=0, error="", warning=""}
{columns=[{Index={type=string}}, {Type={type=string}}], data=[{Index=products, Type=rt}], total=0, error="", warning=""}
{DESC | DESCRIBE} table_name [ LIKE pattern ]
DESCRIBE 语句列出表的列及其相关类型。列包括文档 ID、全文字段和属性。顺序与 INSERT 和 REPLACE 语句中字段和属性的预期顺序相匹配。列类型包括 field、integer、timestamp、ordinal、bool、float、bigint、string 和 mva。ID 列的类型为 bigint。示例:
mysql> DESC rt;
+---------+---------+
| Field | Type |
+---------+---------+
| id | bigint |
| title | field |
| content | field |
| gid | integer |
+---------+---------+
4 rows in set (0.00 sec)
支持可选的 LIKE 子句。语法详情请参阅
SHOW META。
你也可以通过执行查询 select * from <table_name>.@table 来查看表结构。此方法的好处是可以使用 WHERE 子句进行过滤:
select * from tbl.@table where type='text';
+------+-------+------+----------------+
| id | field | type | properties |
+------+-------+------+----------------+
| 2 | title | text | indexed stored |
+------+-------+------+----------------+
1 row in set (0.00 sec)
你还可以对 <your_table_name>.@table 执行许多其他操作,将其视为具有整数和字符串属性列的常规 Manticore 表。
select field from tbl.@table;
select field, properties from tbl.@table where type in ('text', 'uint');
select * from tbl.@table where properties any ('stored');
SHOW CREATE TABLE table_name
打印用于创建指定表的 CREATE TABLE 语句。
Table: tbl
Create Table: CREATE TABLE tbl (
f text indexed stored
) charset_table='non_cont,cont' morphology='icu_chinese'
1 row in set (0.00 sec)
如果你对 percolate 表使用 DESC 语句,它将显示外部表结构,即存储查询的结构。此结构是静态的,所有本地 percolate 表相同:
mysql> DESC pq;
+---------+--------+
| Field | Type |
+---------+--------+
| id | bigint |
| query | string |
| tags | string |
| filters | string |
+---------+--------+
4 rows in set (0.00 sec)
如果你想查看预期的文档结构,请使用以下命令:
DESC <pq table name> table:
mysql> DESC pq TABLE;
+-------+--------+
| Field | Type |
+-------+--------+
| id | bigint |
| title | text |
| gid | uint |
+-------+--------+
3 rows in set (0.00 sec)
同时支持 desc pq table like ...,其工作方式如下:
mysql> desc pq table like '%title%';
+-------+------+----------------+
| Field | Type | Properties |
+-------+------+----------------+
| title | text | indexed stored |
+-------+------+----------------+
1 row in set (0.00 sec)