Deleting an index

Deleting an index is performed in 2 steps:

  1. Index is cleared (similar to TRUNCATE)
  2. All index files are removed from the index folder. All the external index files that were used by the index (such as wordforms, extensions or stopwords) are also deleted. Note that these external files are copied to index folder when CREATE TABLE is used, so the original files specified in CREATE TABLE will not be deleted.

Deleting an index is possible only when the server is running in RT mode. It is possible to delete RT indexes, PQ indexes and distributed indexes.

‹›
  • SQL
  • HTTP
  • PHP
  • Python
  • javascript
  • Java
📋
DROP TABLE products;
‹›
Response
Query OK, 0 rows affected (0.02 sec)

Here is the syntax of the DROP TABLE statement in SQL:

DROP TABLE [IF EXISTS] index_name

When deleting an index via SQL, adding IF EXISTS can be used to delete the index only if it exists. If you try to delete a non-existing index with the IF EXISTS option, nothing happens.

When deleting an index via PHP, you can add an optional silent parameter which works the same as IF EXISTS.

‹›
  • SQL
  • HTTP
  • PHP
  • Python
  • javascript
  • Java
📋
DROP TABLE IF EXISTS products;
‹›
Response
{u'error': u'', u'total': 0, u'warning': u''}

Emptying an index

The index 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 index_name [WITH RECONFIGURE]

When this statement is executed, it clears the RT index completely. It disposes the in-memory data, unlinks all the index data files, and releases the associated binary logs.

An index can also be emptied with DELETE FROM index WHERE id>0, but it's not recommended as it's much slower than TRUNCATE.

‹›
  • SQL
  • HTTP
  • PHP
  • Python
  • javascript
  • Java
📋
TRUNCATE TABLE products;
‹›
Response
Query OK, 0 rows affected (0.02 sec)

One of the possible uses of this command is before attaching an index.

When RECONFIGURE option is used new tokenization, morphology, and other text processing settings specified in the config take effect after the index gets cleared. In case the schema declaration in config is different from the index schema the new schema from config got applied after index get cleared.

With this option clearing and reconfiguring an index becomes one atomic operation.

‹›
  • SQL
  • HTTP
  • PHP
  • Python
  • javascript
  • Java
📋
TRUNCATE TABLE products with reconfigure;
‹›
Response
Query OK, 0 rows affected (0.02 sec)

Manticore cluster

Manticore Search is a highly distributed system and consists of all the needed components to allow you build a highly available and scalable setup of a database for search:

Manticore Search is extremely flexible in terms of how you setup your cluster, there's no limitations and it's up to you how you design it. Just learn the tools mentioned above and use them to achieve your goal.