When working with sharded tables, be aware of the following limitations:
-
Local and Clustered Sharded Tables Cannot Coexist on the Same Nodes: On a set of nodes that participate in a replication cluster, you cannot mix:
- Local sharded tables (created without a cluster prefix:
create table s ... shards='N' rf='1') - Clustered sharded tables (created with a cluster prefix:
create table c:r ... shards='N' rf='M')
Example: Consider a 2-node cluster where:
- Table
swas created independently on each node as a local sharded table - Table
ris replicated across both nodes via the cluster
In this setup, attempting to create a clustered sharded table (
create table c:r ... shards='N' rf='2') on the same nodes will fail. - Local sharded tables (created without a cluster prefix:
-
Cluster Name Consistency:
- The sharding subsystem binds to a single cluster name on first use; all clustered sharded tables on these nodes must use that same cluster name.
- Once the cluster name is chosen, it applies to all subsequent clustered sharded table creations.
Example: If you create your first clustered sharded table with:
create table c:users ... shards='N' rf='M'All subsequent clustered sharded tables must reuse cluster
c:create table c:orders ... shards='N' rf='M' -- works create table d:items ... shards='N' rf='M' -- fails -
No Table Alterations:
- Once a sharded table is created, its structure cannot be modified with
ALTER TABLE. - To change the schema, you must:
- Create a new sharded table with the desired structure
- Copy the data to the new table
- Drop the old table
- Once a sharded table is created, its structure cannot be modified with
-
Shard Count Limit:
- Maximum of 3,000 shards per sharded table.
- This limit applies regardless of cluster configuration or table size.
- Plan your sharding strategy accordingly to stay within this limit.
-
rfandshardsMust Be Quoted Integers:- Both options require a quoted numeric value (
shards='10',rf='2'); unquoted, non-numeric, empty, or fractional values are rejected. - On a standalone (non-clustered) server,
rfmust be'1'. - On a replication cluster,
rfmust be between1and the number of nodes in the cluster.
- Both options require a quoted numeric value (
Manticore Search has a single level of hierarchy for tables.
Unlike other DBMS, there is no concept of grouping tables into databases in Manticore. However, for interoperability with SQL dialects, Manticore accepts SHOW DATABASES statements for interoperability with SQL dialect, statements, but the statement does not return any results.
General syntax:
SHOW TABLES [ LIKE pattern ]
The SHOW TABLESstatement lists all currently active tables along with their types. The existing table types are local, distributed, rt, percolate and template.
- SQL
- JSON
- PHP
- Python
- Python-asyncio
- javascript
- Java
- C#
- Rust
SHOW TABLES;POST /sql?mode=raw -d "SHOW TABLES"$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)[
{
"columns": [
{
"Table": {
"type": "string"
}
},
{
"Type": {
"type": "string"
}
}
],
"data": [
{
"Table": "dist",
"Type": "distributed"
},
{
"Table": "plain",
"Type": "local"
},
{
"Table": "pq",
"Type": "percolate"
},{
"Table": "rt",
"Type": "rt"
},{
"Table": "template",
"Type": "template"
}
],
"total": 5,
"error": "",
"warning": ""
}
]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=""}Optional LIKE clause is supported for filtering tables by name.
- SQL
- JSON
- PHP
- Python
- Python-asyncio
- javascript
- Java
- C#
- Rust
SHOW TABLES LIKE 'pro%';POST /sql?mode=raw -d "SHOW TABLES LIKE 'pro%';"$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)[
{
"columns": [
{
"Table": {
"type": "string"
}
},
{
"Type": {
"type": "string"
}
}
],
"data": [
{
"Table": "products",
"Type": "distributed"
}
],
"total": 1,
"error": "",
"warning": ""
}
]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 ]
The DESCRIBE statement lists the table columns and their associated types. The columns are document ID, full-text fields, and attributes. The order matches the order in which fields and attributes are expected by INSERT and REPLACE statements. Column types include field, integer, timestamp, ordinal, bool, float, bigint, string, and mva. ID column will be typed as bigint. Example:
mysql> DESC rt;
+---------+---------+
| Field | Type |
+---------+---------+
| id | bigint |
| title | field |
| content | field |
| gid | integer |
+---------+---------+
4 rows in set (0.00 sec)
An optional LIKE clause is supported. Refer to SHOW META for its syntax details.
You can also view the table schema by executing the query select * from <table_name>.@table. The benefit of this method is that you can use the WHERE clause for filtering:
- SQL
- JSON
select * from tbl.@table where type='text';POST /sql?mode=raw -d "select * from tbl.@table where type='text';"+------+-------+------+----------------+
| id | field | type | properties |
+------+-------+------+----------------+
| 2 | title | text | indexed stored |
+------+-------+------+----------------+
1 row in set (0.00 sec)[{
"columns":[{"id":{"type":"long long"}},{"field":{"type":"string"}},{"type":{"type":"string"}},{"properties":{"type":"string"}}],
"data":[
{"id":2,"field":"title","type":"text","properties":"indexed stored"}
],
"total":1,
"error":"",
"warning":""
}]You can also perform many other actions on <your_table_name>.@table considering it as a regular Manticore table with columns consisting of integer and string attributes.
- SQL
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 [ OPTION output_words = 'list' | 'file' ]
Prints the CREATE TABLE statement used to create the specified table.
The output_words option allows you to control how external file settings (such as stopwords, exceptions, wordforms, hitless_words) are displayed:
'list'(default): Displays the content of the files as inline lists using the*_listoptions (e.g.stopwords_list='word1; word2').'file': Displays the file paths using the original options (e.g.stopwords='/path/to/file').
- SQL
- JSON
SHOW CREATE TABLE tbl\GPOST /sql?mode=raw -d "SHOW CREATE TABLE tbl" 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)[{
"columns":[{"Table":{"type":"string"}},{"Create Table":{"type":"string"}}],
"data":[
{"Table":"tbl","Create Table":"CREATE TABLE tbl (\nf text)"}
],
"total":1,
"error":"",
"warning":""
}]If you use the DESC statement on a percolate table, it will display the outer table schema, which is the schema of stored queries. This schema is static and the same for all local percolate tables:
mysql> DESC pq;
+---------+--------+
| Field | Type |
+---------+--------+
| id | bigint |
| query | string |
| tags | string |
| filters | string |
+---------+--------+
4 rows in set (0.00 sec)
If you want to view the expected document schema, use the following command:
DESC <pq table name> table:
mysql> DESC pq TABLE;
+-------+--------+
| Field | Type |
+-------+--------+
| id | bigint |
| title | text |
| gid | uint |
+-------+--------+
3 rows in set (0.00 sec)
Also desc pq table like ... is supported and works as follows:
mysql> desc pq table like '%title%';
+-------+------+----------------+
| Field | Type | Properties |
+-------+------+----------------+
| title | text | indexed stored |
+-------+------+----------------+
1 row in set (0.00 sec)
Deleting a table is performed in 2 steps internally:
- Table is cleared (similar to TRUNCATE)
- All table files are removed from the table folder. All the external table files that were used by the table (such as wordforms, extensions or stopwords) are also deleted. Note that these external files are copied to the table folder when
CREATE TABLEis used, so the original files specified inCREATE TABLEwill not be deleted.
Deleting a table is possible only when the server is running in the RT mode. It is possible to delete RT tables, PQ tables and distributed tables.
- SQL
- JSON
- PHP
- Python
- Python-asyncio
- javascript
- Java
- C#
- Rust
DROP TABLE products;POST /cli -d "DROP TABLE products"$params = [ 'table' => 'products' ];
$response = $client->indices()->drop($params);utilsApi.sql('DROP TABLE products')await utilsApi.sql('DROP TABLE products')res = await utilsApi.sql('DROP TABLE products');sqlresult = utilsApi.sql("DROP TABLE products", true);sqlresult = utilsApi.Sql("DROP TABLE products", true);let sqlresult = utils_api.sql("DROP TABLE products", Some(true)).await;Query OK, 0 rows affected (0.02 sec){
"total":0,
"error":"",
"warning":""
}Array
(
[total] => 0
[error] =>
[warning] =>
){u'error': u'', u'total': 0, u'warning': u''}{u'error': u'', u'total': 0, u'warning': u''}{"total":0,"error":"","warning":""}{total=0, error=, warning=}{total=0, error="", warning=""}{total=0, error="", warning=""}Here is the syntax of the DROP TABLE statement in SQL:
DROP TABLE [IF EXISTS] table_name
When deleting a table via SQL, adding IF EXISTS can be used to delete the table only if it exists. If you try to delete a non-existing table with the IF EXISTS option, nothing happens.
When deleting a table via PHP, you can add an optional silent parameter which works the same as IF EXISTS.
- SQL
- JSON
- PHP
- Python
- Python-asyncio
- javascript
- Java
- C#
- Rust
DROP TABLE IF EXISTS products;POST /cli -d "DROP TABLE IF EXISTS products"$params =
[
'table' => 'products',
'body' => ['silent' => true]
];
$client->indices()->drop($params);utilsApi.sql('DROP TABLE IF EXISTS products')await utilsApi.sql('DROP TABLE IF EXISTS products')res = await utilsApi.sql('DROP TABLE IF EXISTS products');sqlresult = utilsApi.sql("DROP TABLE IF EXISTS products", true);sqlresult = utilsApi.Sql("DROP TABLE IF EXISTS products", true);let sqlresult = utils_api.sql("DROP TABLE IF EXISTS products", Some(true)).await;{u'error': u'', u'total': 0, u'warning': u''}{u'error': u'', u'total': 0, u'warning': u''}{"total":0,"error":"","warning":""}{total=0, error=, warning=}{total=0, error="", warning=""}{total=0, error="", warning=""}The table can be emptied with a TRUNCATE TABLE SQL statement or with a truncate() PHP client function.
Here is the syntax for the SQL statement:
TRUNCATE TABLE table_name [WITH RECONFIGURE]
When this statement is executed, it clears the RT or distributed table completely. It disposes the in-memory data, unlinks all the table data files, and releases the associated binary logs.
For emptying a distributed table, use syntax without the with reconfigure option. Simply execute the standard TRUNCATE statement against your distributed table.
TRUNCATE TABLE distributed_table
NOTE: Emptying a distributed table requires Manticore Buddy. If it doesn't work, make sure Buddy is installed.
A table can also be emptied with DELETE FROM index WHERE id>0, but it's not recommended as it's slower than TRUNCATE.
- SQL
- JSON
- PHP
- Python
- Python-asyncio
- javascript
- Java
- C#
- Rust
TRUNCATE TABLE products;POST /cli -d "TRUNCATE TABLE products"$params = [ 'table' => 'products' ];
$response = $client->indices()->truncate($params);utilsApi.sql('TRUNCATE TABLE products')await utilsApi.sql('TRUNCATE TABLE products')res = await utilsApi.sql('TRUNCATE TABLE products');utilsApi.sql("TRUNCATE TABLE products", true);utilsApi.Sql("TRUNCATE TABLE products", true);utils_api.sql("TRUNCATE TABLE products", Some(true)).await;Query OK, 0 rows affected (0.02 sec){
"total":0,
"error":"",
"warning":""
}Array(
[total] => 0
[error] =>
[warning] =>
){u'error': u'', u'total': 0, u'warning': u''}{u'error': u'', u'total': 0, u'warning': u''}{"total":0,"error":"","warning":""}{total=0, error=, warning=}{total=0, error="", warning=""}{total=0, error="", warning=""}One of the possible uses of this command is before attaching a table.
When RECONFIGURE option is used new tokenization, morphology, and other text processing settings specified in the config take effect after the table gets cleared. In case the schema declaration in config is different from the table schema the new schema from config got applied after table get cleared.
NOTE: The
RECONFIGUREoption only makes sense in Plain mode, where it applies the settings from the configuration file. Note thatTRUNCATEis only supported for RT tables, and theRECONFIGUREoption can only be used with RT tables when Manticore is running in Plain mode.
With this option clearing and reconfiguring a table becomes one atomic operation.
- SQL
- HTTP
- PHP
- Python
- Python-asyncio
- javascript
- Java
- C#
- Rust
TRUNCATE TABLE products with reconfigure;POST /cli -d "TRUNCATE TABLE products with reconfigure"$params = [ 'table' => 'products', 'with' => 'reconfigure' ];
$response = $client->indices()->truncate($params);utilsApi.sql('TRUNCATE TABLE products WITH RECONFIGURE')await utilsApi.sql('TRUNCATE TABLE products WITH RECONFIGURE')res = await utilsApi.sql('TRUNCATE TABLE products WITH RECONFIGURE');utilsApi.sql("TRUNCATE TABLE products WITH RECONFIGURE", true);utilsApi.Sql("TRUNCATE TABLE products WITH RECONFIGURE" ,true);utils_api.sql("TRUNCATE TABLE products WITH RECONFIGURE", Some(true)).await;Query OK, 0 rows affected (0.02 sec){
"total":0,
"error":"",
"warning":""
}Array(
[total] => 0
[error] =>
[warning] =>
){u'error': u'', u'total': 0, u'warning': u''}{u'error': u'', u'total': 0, u'warning': u''}{"total":0,"error":"","warning":""}{total=0, error=, warning=}{total=0, error="", warning=""}