giza_sphinxsearch v0.1.0 Giza.SphinxQL

Query building helper functions for SphinxQL requests (http://sphinxsearch.com/docs/devel.html#sphinxql-reference). This is the recommended way to query Sphinx (for client speed particularly) and will be the most supported style in Giza going forward. SphinxQL is very close to standard SQL with a few non-supported terms that wouldn’t make sence in the search world and a few extras that only make sense in Sphinx’s world. All Sphinx functionality is accessable through this method.

Summary

Functions

Return a SphinxQL query augmented with a CALL statement. A string is acceptable input

Returns a SphinxQL query augmented with an index to select from

Returns an api query augmented with a limit for amount of returned documents. Note that Sphinx also allows for setting an internal limit in configuration. Only an integer is acceptable input

Returns a SphinxQL query augmented with a where clause which will be formated as a MATCH query, a common way of asking Sphinx for search matches on a word or phrase (word bag)

Return a http api query structure with default values

Returns an api query augmented with a limit for amount of returned documents. Only an integer is acceptable input. This is normally used to support pagination

Return a SphinxQL query with it’s raw field set allowing to run a custom client created query. Raw overrides other options such as select, where, etc

Return a SphinxQL query augmented with a select statement. Either a string (binary) or list of fields is acceptable input

Send a query to be executed after preprocessing of the SphinxqlQuery structure. Returns a tuple with :ok or :error and the error message if applicable

Shortcut helper function to form a suggestion query. Options can be passed to change the default limit and max edits (amount of levenstein distance acceptable, so 4 would mean 4 characters can be wrong)

Returns a SphinxQL query with a where clause added. A string representing the whole where part of your query is the only accepted input

Functions

call(query, call)

Return a SphinxQL query augmented with a CALL statement. A string is acceptable input.

Examples

iex> Giza.SphinxQL.new() |> Giza.SphinxQL.call("QSUGGEST('subtei', 'posts_index')") |> Giza.SphinxQL.send()
from(query, index)

Returns a SphinxQL query augmented with an index to select from.

Examples

iex> Giza.SphinxQL.new() |> Giza.SphinxQL.from("posts")
limit(query, limit)

Returns an api query augmented with a limit for amount of returned documents. Note that Sphinx also allows for setting an internal limit in configuration. Only an integer is acceptable input.

Examples

iex> Giza.SphinxQL.new() |> Giza.SphinxQL.limit(1)
match(query, search_phrase)

Returns a SphinxQL query augmented with a where clause which will be formated as a MATCH query, a common way of asking Sphinx for search matches on a word or phrase (word bag)

Examples

iex> Giza.SphinxQL.new() |> Giza.SphinxQL.match("Subetei the Swift")
new()

Return a http api query structure with default values

Examples

iex> Giza.SphinxQL.new() |> ...
offset(query, offset)

Returns an api query augmented with a limit for amount of returned documents. Only an integer is acceptable input. This is normally used to support pagination.

Examples

iex> Giza.SphinxQL.new() |> Giza.SphinxQL.offset(10)
raw(query, raw_query_string)

Return a SphinxQL query with it’s raw field set allowing to run a custom client created query. Raw overrides other options such as select, where, etc.

Examples

iex> Giza.SphinxQL.new() |> Giza.SphinxQL.raw("SELECT id, WEIGHT() as w FROM posts_index WHERE MATCH('subetei the swift')")
select(query, fields)

Return a SphinxQL query augmented with a select statement. Either a string (binary) or list of fields is acceptable input.

Examples

iex> Giza.SphinxQL.new() |> Giza.SphinxQL.select(["id", "WEIGHT() as w"])
send(query)

Send a query to be executed after preprocessing of the SphinxqlQuery structure. Returns a tuple with :ok or :error and the error message if applicable.

Examples

iex> Giza.SphinxQL.new() |> Giza.SphinxQL.raw("SELECT id FROM test_index WHERE MATCH('great kahn')") |> Giza.SphinxQL.send()
suggest(query, index, phrase, opts)

Shortcut helper function to form a suggestion query. Options can be passed to change the default limit and max edits (amount of levenstein distance acceptable, so 4 would mean 4 characters can be wrong)

Examples

iex> Giza.SphinxQL.new() |> Giza.SphinxQL.suggest('sbetei', 'posts_index', [limit: 3, max_edits: 4])
where(query, where)

Returns a SphinxQL query with a where clause added. A string representing the whole where part of your query is the only accepted input.

Examples

iex> Giza.SphinxQL.new() |> Giza.SphinxQL.where("MATCH('tengri') AND room = 'mongol lounge'")