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

cluster_add_table(cluster, table)

Add a table to a replication cluster.

Examples

iex> SearchTables.cluster_add_table("my_cluster", "products")
{:ok, %SphinxqlResponse{}}

cluster_delete(cluster, table, where_clause)

Delete from a replicated table using cluster:table notation.

Examples

iex> SearchTables.cluster_delete("my_cluster", "products", "id = 1")
{:ok, %SphinxqlResponse{}}

cluster_drop_table(cluster, table)

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{}}

cluster_insert(cluster, table, columns, values)

Insert into a replicated table using cluster:table notation.

Examples

iex> SearchTables.cluster_insert("my_cluster", "products", ["id", "title"], [1, "Laptop"])
{:ok, %SphinxqlResponse{}}

cluster_replace(cluster, table, columns, values)

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_cluster(name)

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_cluster(name, path)

create_distributed_table(name, parts)

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_distributed_table(name, parts, opts)

create_table(name, schema)

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{}}

create_table(name, schema, opts)

create_table_if_not_exists(name, schema)

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{}}

create_table_if_not_exists(name, schema, opts)

create_table_like(name, existing)

Clone a table's schema.

Examples

iex> SearchTables.create_table_like("products_copy", "products")
{:ok, %SphinxqlResponse{}}

delete(table, where_clause)

Delete documents matching a condition.

Examples

iex> SearchTables.delete("products", "id = 1")
{:ok, %SphinxqlResponse{}}

delete_cluster(name)

Delete a replication cluster. Tables survive as local non-replicated tables.

Examples

iex> SearchTables.delete_cluster("my_cluster")
{:ok, %SphinxqlResponse{}}

describe_table(name)

Return the schema of a table.

Examples

iex> SearchTables.describe_table("products")
{:ok, %SphinxqlResponse{fields: ["Field", "Type", "Properties"], matches: [...]}}

drop_table(name)

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{}}

drop_table(name, opts)

flush_table(name)

Force the RAM chunk to a new disk chunk. Important before planned shutdowns.

Examples

iex> SearchTables.flush_table("products")
{:ok, %SphinxqlResponse{}}

insert(table, columns, values)

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_cluster(name, host)

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{}}

join_cluster(name, host, path)

optimize_table(name)

Merge disk chunks. Run periodically to avoid read amplification.

Examples

iex> SearchTables.optimize_table("products")
{:ok, %SphinxqlResponse{}}

replace(table, columns, values)

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{}}

show_create_table(name)

Return the DDL statement that would recreate the table.

Examples

iex> SearchTables.show_create_table("products")
{:ok, %SphinxqlResponse{}}

show_table_status(name)

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{}}

truncate_table(name)

Wipe all data from a table while preserving its schema.

Examples

iex> SearchTables.truncate_table("products")
{:ok, %SphinxqlResponse{}}

update(table, attrs, where_clause)

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{}}