Giza.ManticoreQL
(giza_sphinxsearch v2.0.0)
Copy Markdown
Query building helper functions for ManticoreQL. Manticore Search is a fork of Sphinx Search
with active development and new features. This module delegates the standard query-composing
interface to ManticoreQL and is the place to add Manticore-specific extensions.
Summary
Functions
Word-level autocomplete via CALL SUGGEST. Returns candidate completions for the given
partial word against the specified index dictionary.
Appends a FACET clause to the query. Multiple calls chain additional facets. Manticore reuses the base result set for each facet, so the total cost is only marginally more than the plain query.
Adds HIGHLIGHT() to the SELECT list so Manticore annotates matching keywords in stored
fields. Requires the table to have stored_fields configured.
Sets a KNN (k-nearest-neighbour) vector search clause in WHERE. Requires the table to
have a float_vector attribute with an HNSW index.
See Giza.SphinxQL.new/0.
Executes a percolate (reverse search) query — matches stored queries in a percolate table against one or more incoming documents.
Functions
Word-level autocomplete via CALL SUGGEST. Returns candidate completions for the given
partial word against the specified index dictionary.
Options:
:limit- max suggestions (default: 5):max_edits- Levenshtein distance tolerance (default: 4)
Examples
iex> ManticoreQL.autocomplete("elxi", "posts_index")
{:ok, %SphinxqlResponse{}}
iex> ManticoreQL.autocomplete("elxi", "posts_index", limit: 3, max_edits: 2)
{:ok, %SphinxqlResponse{}}
See Giza.SphinxQL.call/2.
Appends a FACET clause to the query. Multiple calls chain additional facets. Manticore reuses the base result set for each facet, so the total cost is only marginally more than the plain query.
Options:
:order- ORDER BY expression string, e.g."COUNT(*) DESC":limit- integer cap on facet rows returned
Examples
iex> ManticoreQL.new()
|> ManticoreQL.from("products")
|> ManticoreQL.match("phone")
|> ManticoreQL.facet("brand_id")
|> ManticoreQL.facet("price", order: "COUNT(*) DESC", limit: 10)
|> ManticoreQL.send()
See Giza.SphinxQL.from/2.
Adds HIGHLIGHT() to the SELECT list so Manticore annotates matching keywords in stored
fields. Requires the table to have stored_fields configured.
Options are passed as keyword pairs and become key='value' inside HIGHLIGHT({...}).
Common options: before_match, after_match, around, limit, limit_passages.
Examples
iex> ManticoreQL.new()
|> ManticoreQL.from("articles")
|> ManticoreQL.match("elixir")
|> ManticoreQL.highlight()
|> ManticoreQL.send()
iex> ManticoreQL.new()
|> ManticoreQL.from("articles")
|> ManticoreQL.match("elixir")
|> ManticoreQL.highlight(before_match: "<em>", after_match: "</em>", limit: 200)
|> ManticoreQL.send()
Sets a KNN (k-nearest-neighbour) vector search clause in WHERE. Requires the table to
have a float_vector attribute with an HNSW index.
Typically combine with select/2 to also retrieve knn_dist() in results.
Examples
iex> ManticoreQL.new()
|> ManticoreQL.select(["id", "title", "knn_dist()"])
|> ManticoreQL.from("articles")
|> ManticoreQL.knn("embedding", 5, [0.1, 0.2, 0.3, 0.4])
|> Giza.send()
See Giza.SphinxQL.meta/0.
See Giza.SphinxQL.new/0.
Executes a percolate (reverse search) query — matches stored queries in a percolate table against one or more incoming documents.
doc is a JSON string. docs is a list of JSON strings that will be wrapped in a JSON
array.
Examples
iex> ManticoreQL.percolate("pq_alerts", ~s({"title": "breaking news"}))
{:ok, %SphinxqlResponse{}}
iex> ManticoreQL.percolate("pq_alerts", [~s({"title": "foo"}), ~s({"title": "bar"})])
{:ok, %SphinxqlResponse{}}
See Giza.SphinxQL.raw/2.