Skip to content

Instantly share code, notes, and snippets.

@Moosh-be
Last active February 20, 2019 02:30
Show Gist options
  • Save Moosh-be/16ab03c22cae5c5c33a6 to your computer and use it in GitHub Desktop.
Save Moosh-be/16ab03c22cae5c5c33a6 to your computer and use it in GitHub Desktop.
Sphinxsearch : querystring sample for SphinxSE
http://sphinxsearch.com/docs/current.html#sphinxse-using
#search 'paris'
query='paris'
#search 'paris' only in index 'foo'
query='paris;index=foo'
#search 'paris' but only 5 first results
query='paris;limit=5'
#search 'paris' but only 10 next results
query='paris;offset=5;limit=10'
#search 'paris' only in indexes 'foo' and bar
query='paris;index=foo,bar'
#search 'paris' and add a comment in the query log
query='paris;comment=this is my comment'
query='paris tour;mode=all'; (default)
query='paris tour;mode=any';
query='paris tour;mode=phrase';
query='paris tour;mode=boolean';
query='paris tour;mode=extended';
#sort - match sorting mode. Must be one of "relevance", "attr_desc", "attr_asc", "time_segments", or "extended". In all modes besides "relevance" attribute name (or sorting clause for "extended") is also required after a colon:
query='Paris tour;sort=attr_asc:group_id';
query='Paris tour;sort=extended:@weight desc, group_id asc';
query='Paris tour;minid=100;maxid:10000';
weights - comma-separated list of weights to be assigned to Sphinx full-text fields:
query='test;weights=1,2,3;';
filter, !filter - comma-separated attribute name and a set of values to match:
# only include groups 1, 5 and 19
query='test;filter=group_id,1,5,19;';
# exclude groups 3 and 11
query='test;!filter=group_id,3,11;';
range, !range - comma-separated (integer or bigint) Sphinx attribute name, and min and max values to match:
# include groups from 3 to 7, inclusive
query='test;range=group_id,3,7;';
# exclude groups from 5 to 25
query='test;!range=group_id,5,25;';
So "foo lower than" is "range from 0 to value -1
# lower than 10
query='test;range=foo,0,9;';
And "foo bigger than" is "exclude range from 0 to value
# lower than 10
query='test;!range=foo,0,10;';
floatrange, !floatrange - comma-separated (floating point) Sphinx attribute name, and min and max values to match:
# filter by a float size
query='test;floatrange=size,2,3;';
# pick all results within 1000 meter from geoanchor
query='test;floatrange=@geodist,0,1000;';
# maxmatches - per-query max matches value
WHERE query='test;maxmatches=2000;';
( defalut value is same than google : 1000 )
# cutoff - maximum allowed matches
query='test;cutoff=10000;';
# maxquerytime - maximum allowed query time (in milliseconds)
query='test;maxquerytime=1000;';
# groupby - group-by function and attribute, corresponding to SetGroupBy() API call:
query='test;groupby=day:published_ts;';
query='test;groupby=attr:group_id;';
#groupsort - group-by sorting clause:
query='test;groupsort=@count desc;';
#distinct - an attribute to compute COUNT(DISTINCT) for when doing group-by, as in SetGroupDistinct() API call:
query='test;groupby=attr:country_id;distinct=site_id';
# indexweights - comma-separated list of index names and weights to use when searching through several indexes:
query='test;indexweights=idx_exact,2,idx_stemmed,1;';
# fieldweights - comma-separated list of per-field weights that can be used by the ranker:
query='test;fieldweights=title,10,abstract,3,content,1;';
# select - a string with expressions to compute
query='test;select=2*a+3*b as myexpr;';
# host, port - remote searchd host name and TCP port, respectively:
query='test;host=sphinx-test.loc;port=7312;';
# ranker - a ranking function to use with "extended" matching mode, Known values are "proximity_bm25", "bm25", "none", "wordcount", "proximity", "matchany", "fieldmask", "sph04", "expr:EXPRESSION"
query='test;mode=extended;ranker=bm25;';
query='test;mode=extended;ranker=expr:sum(lcs);';
# geoanchor - geodistance anchor, as in SetGeoAnchor() API call. Takes 4 parameters which are latitude and longitude attribute names, and anchor point coordinates respectively:
query='test;geoanchor=latattr,lonattr,0.123,0.456';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment