Giza.SearchTables
(giza_sphinxsearch v2.0.0)
Copy Markdown
Table management functions for Manticore Search. Covers DDL (table lifecycle), DML (writing to RT tables), clustered DML (replication-aware writes), replication cluster management, and maintenance operations.
Table Create Options
@see https://manual.manticoresearch.com/Introduction @see https://manual.manticoresearch.com/Searching/Sorting_and_ranking#Ranking-overview @see https://manual.manticoresearch.com/Searching/Spell_correction#Fuzzy-Search
Summary
Functions
Add a table to a replication cluster.
Delete from a replicated table using cluster:table notation.
Remove a table from a replication cluster. The table survives as a local non-replicated table.
Insert into a replicated table using cluster:table notation.
Full upsert into a replicated table using cluster:table notation.
Create a replication cluster.
Create a distributed table that fans queries out to local shards and/or remote agents.
Create a real-time table with the given schema definition.
Idempotent table creation — uses IF NOT EXISTS.
Clone a table's schema.
Delete documents matching a condition.
Delete a replication cluster. Tables survive as local non-replicated tables.
Return the schema of a table.
Drop a table. Pass if_exists: true to suppress errors when the table doesn't exist.
Force the RAM chunk to a new disk chunk. Important before planned shutdowns.
Insert a row into a table.
Join an existing replication cluster at the given host.
Merge disk chunks. Run periodically to avoid read amplification.
Full upsert by document id — replaces the entire row if it exists.
Return the DDL statement that would recreate the table.
Show table status — document count, disk size, chunk count, etc.
Useful for deciding when to run optimize_table/1.
Wipe all data from a table while preserving its schema.
Partial attribute update. Only attributes (not full-text fields) can be updated.
Functions
Add a table to a replication cluster.
Examples
iex> SearchTables.cluster_add_table("my_cluster", "products")
{:ok, %SphinxqlResponse{}}
Delete from a replicated table using cluster:table notation.
Examples
iex> SearchTables.cluster_delete("my_cluster", "products", "id = 1")
{:ok, %SphinxqlResponse{}}
Remove a table from a replication cluster. The table survives as a local non-replicated table.
Examples
iex> SearchTables.cluster_drop_table("my_cluster", "products")
{:ok, %SphinxqlResponse{}}
Insert into a replicated table using cluster:table notation.
Examples
iex> SearchTables.cluster_insert("my_cluster", "products", ["id", "title"], [1, "Laptop"])
{:ok, %SphinxqlResponse{}}
Full upsert into a replicated table using cluster:table notation.
Examples
iex> SearchTables.cluster_replace("my_cluster", "products", ["id", "title"], [1, "Laptop"])
{:ok, %SphinxqlResponse{}}
Create a replication cluster.
Examples
iex> SearchTables.create_cluster("my_cluster")
{:ok, %SphinxqlResponse{}}
iex> SearchTables.create_cluster("my_cluster", "/var/data/cluster")
{:ok, %SphinxqlResponse{}}
Create a distributed table that fans queries out to local shards and/or remote agents.
parts is a keyword list whose keys are :local or :agent:
[local: "shard1", local: "shard2", agent: "host:port:remote"]Examples
iex> SearchTables.create_distributed_table("dist_products",
...> [local: "shard1", local: "shard2", agent: "10.0.0.2:9312:remote_shard"])
{:ok, %SphinxqlResponse{}}
Create a real-time table with the given schema definition.
schema may be a raw SQL string or a list of {name, type} tuples.
Examples
iex> SearchTables.create_table("products", "title text, price uint")
{:ok, %SphinxqlResponse{}}
iex> SearchTables.create_table("products", [{"title", "text"}, {"price", "uint"}])
{:ok, %SphinxqlResponse{}}
iex> SearchTables.create_table("products", "title text", "morphology='stem_en'")
{:ok, %SphinxqlResponse{}}
Idempotent table creation — uses IF NOT EXISTS.
Accepts the same arguments as create_table/2,3.
Examples
iex> SearchTables.create_table_if_not_exists("products", "title text, price uint")
{:ok, %SphinxqlResponse{}}
Clone a table's schema.
Examples
iex> SearchTables.create_table_like("products_copy", "products")
{:ok, %SphinxqlResponse{}}
Delete documents matching a condition.
Examples
iex> SearchTables.delete("products", "id = 1")
{:ok, %SphinxqlResponse{}}
Delete a replication cluster. Tables survive as local non-replicated tables.
Examples
iex> SearchTables.delete_cluster("my_cluster")
{:ok, %SphinxqlResponse{}}
Return the schema of a table.
Examples
iex> SearchTables.describe_table("products")
{:ok, %SphinxqlResponse{fields: ["Field", "Type", "Properties"], matches: [...]}}
Drop a table. Pass if_exists: true to suppress errors when the table doesn't exist.
Examples
iex> SearchTables.drop_table("products")
{:ok, %SphinxqlResponse{}}
iex> SearchTables.drop_table("products", if_exists: true)
{:ok, %SphinxqlResponse{}}
Force the RAM chunk to a new disk chunk. Important before planned shutdowns.
Examples
iex> SearchTables.flush_table("products")
{:ok, %SphinxqlResponse{}}
Insert a row into a table.
columns is a list of column name strings. values is a list of corresponding
values — strings are automatically single-quoted, numbers are left bare.
Examples
iex> SearchTables.insert("products", ["id", "title", "price"], [1, "Laptop", 999])
{:ok, %SphinxqlResponse{}}
Join an existing replication cluster at the given host.
Examples
iex> SearchTables.join_cluster("my_cluster", "10.0.0.1:9312")
{:ok, %SphinxqlResponse{}}
iex> SearchTables.join_cluster("my_cluster", "10.0.0.1:9312", "/var/data/cluster")
{:ok, %SphinxqlResponse{}}
Merge disk chunks. Run periodically to avoid read amplification.
Examples
iex> SearchTables.optimize_table("products")
{:ok, %SphinxqlResponse{}}
Full upsert by document id — replaces the entire row if it exists.
Examples
iex> SearchTables.replace("products", ["id", "title", "price"], [1, "Updated Laptop", 899])
{:ok, %SphinxqlResponse{}}
Return the DDL statement that would recreate the table.
Examples
iex> SearchTables.show_create_table("products")
{:ok, %SphinxqlResponse{}}
Show table status — document count, disk size, chunk count, etc.
Useful for deciding when to run optimize_table/1.
Examples
iex> SearchTables.show_table_status("products")
{:ok, %SphinxqlResponse{}}
Wipe all data from a table while preserving its schema.
Examples
iex> SearchTables.truncate_table("products")
{:ok, %SphinxqlResponse{}}
Partial attribute update. Only attributes (not full-text fields) can be updated.
attrs is a keyword list or map of {attribute, value} pairs.
Examples
iex> SearchTables.update("products", [price: 799], "id = 1")
{:ok, %SphinxqlResponse{}}
iex> SearchTables.update("products", %{"price" => 799}, "id = 1")
{:ok, %SphinxqlResponse{}}