Giza.SphinxQL.Recipe (giza_sphinxsearch v1.0.7)
Query building helper functions for SphinxQL designed in commonly useful ways. Provides guidance when trying to take advantage of advanced search functionality without having to know every nuance of sphinx' query language.
Link to this section Summary
Functions
Search on a string and add on as many filters as wanted. This can be used to add simple constraints to a search.
Influence your search results by how recently they were added or updated (or whatever the date field you pass represents). For the example below ensure you are selecting the date in your index as a unix timestamp (mysql: UNIX_TIMESTAMP(updated_timestamp), postgres: extract(epoch from updated_timestamp)).
Link to this section Functions
match_and_filter(query, search_string, filters)
Search on a string and add on as many filters as wanted. This can be used to add simple constraints to a search.
Example
# Show comments for a particular post only by a certain author
iex> SphinxQL.new()
|> SphinxQL.from("blog_comments")
|> SphinxQL.Recipe.match_and_filter("subetei", post_id: 45, author: "Khasar Borjigin")
|> SphinxQL.send()
%SphinxqlResponse{ .. }
weigh_by_date(query, timestamp_field \\ "updated_timestamp")
Influence your search results by how recently they were added or updated (or whatever the date field you pass represents). For the example below ensure you are selecting the date in your index as a unix timestamp (mysql: UNIX_TIMESTAMP(updated_timestamp), postgres: extract(epoch from updated_timestamp)).
Example
iex> SphinxQL.new()
|> SphinxQL.from("blog_posts")
|> SphinxQL.match("red clown")
|> SphinxQL.Recipe.weigh_by_date("last_updated_timestamp")
|> SphinxQL.send()
%SphinxqlResponse{ .. }