Search query configuration object. More...
#include <sphinxclient.h>
Public Types | |
typedef std::map< std::string, std::pair< AttributeType_t, std::map< uint64_t, Value_t > > > | AttributeOverrides_t |
Type of attribute overrides return struct. | |
Public Member Functions | |
SearchConfig_t (const SearchConfig_t &from) | |
SearchConfig_t & | operator= (const SearchConfig_t &from) |
SearchConfig_t (SearchCommandVersion_t cmdVer=VER_COMMAND_SEARCH_2_0_5) | |
~SearchConfig_t () | |
void | addRangeFilter (const std::string &attrName, uint64_t minValue, uint64_t maxValue, bool excludeFlag=false) |
Adds range attribute filter to search config. | |
void | addEnumFilter (const std::string &attrName, const Int64Array_t &values, bool excludeFlag=false) |
Adds enumeration filter to search config. | |
void | addEnumFilter (const std::string &attrName, const IntArray_t &values, bool excludeFlag=false) |
Adds enumeration filter to search config. | |
void | addFloatRangeFilter (const std::string &attrName, float minValue, float maxValue, bool excludeFlag=false) |
Adds float range attribute filter to search config. | |
void | addAttributeOverride (const std::string &attrName, AttributeType_t attrType, uint64_t docId, const Value_t &value) |
Attribute value override for specified document. | |
void | addAttributeOverride (const std::string &attrName, AttributeType_t attrType, const std::map< uint64_t, Value_t > &values) |
Attribute value override for specified documents. | |
bool | getFilter (int index, std::string &attrname, bool &exclude, float &minValue, float &maxValue) const |
bool | getFilter (int index, std::string &attrname, bool &exclude, uint64_t &minValue, uint64_t &maxValue) const |
bool | getFilter (int index, std::string &attrname, bool &exclude, Int64Array_t &values) const |
unsigned | getFilterCount () const |
const Filter_t * | getFilter (int index) const |
SearchCommandVersion_t | getCommandVersion () const |
Get seatch command version. | |
void | setPaging (uint32_t msgOffset, uint32_t msgLimit) |
void | setMatchMode (MatchMode_t matchMode) |
Set query matching mode. | |
void | setSorting (SortMode_t sortMode, const std::string &sortBy="") |
void | setRanking (RankingMode_t rankingMode, const std::string &rankExpr="") |
void | setGrouping (GroupFunction_t groupFunction, const std::string &groupBy="", const std::string &groupSort="") |
void | setGroupDistinctAttribute (const std::string &attributeName) |
Set count-distinct attribute (its name) for group-by query. | |
void | setMaxMatches (int maxMatches) |
Set maximum matches to search for (internal queue size). | |
void | setMaxQueryTime (uint32_t maxQueryTime) |
Set max query duration, milliseconds (default is 0, do not limit). | |
void | setSearchedIndexes (const std::string &indexNames) |
Set index names to search in. | |
void | setIndexWeight (const std::string &indexName, uint32_t weight) |
void | setFieldWeight (const std::string &fieldName, uint32_t weight) |
void | setSearchCutoff (uint32_t searchCutOff) |
stop searching after cutoff matches (default 0 - disabled) | |
void | setRetries (uint32_t distRetryCount, uint32_t distRetryDelay) |
void | setGeoAnchorPoints (const std::vector< GeoAnchorPoint_t > &anchorPoints) |
Set array of geo anchor points to calculate geodist. | |
void | setQueryComment (const std::string &queryComment) |
Set comment on the query. | |
void | setSelectClause (const std::string &selectClause) |
uint32_t | getPagingOffset () const |
Get current paging offset. | |
uint32_t | getPagingLimit () const |
Get current paging limit. | |
MatchMode_t | getMatchMode () const |
Get current matching mode. | |
SortMode_t | getSortingMode () const |
Get current sorting mode. | |
const std::string & | getSortingExpr () const |
Get current sorting expression. | |
RankingMode_t | getRankingMode () const |
Get current ranking mode. | |
const std::string & | getRankingExpr () const |
Get current ranking expression. | |
GroupFunction_t | getGroupingFunction () const |
Get current grouping function. | |
const std::string & | getGroupByExpr () const |
Get group-by expression. | |
const std::string & | getGroupSortExpr () const |
Get group sorting expression. | |
const std::string & | getGroupDistinctAttribute () const |
Get attribute name to calculate distinc count per group. | |
int | getMaxMatches () const |
Get maximum match count. | |
uint32_t | getMaxQueryTime () const |
Get maximum query duration. | |
const std::string & | getSearchedIndexes () const |
Get indexes to be searched. | |
const std::map< std::string, uint32_t > & | getIndexWeights () const |
Get map of per-index weights. | |
const std::map< std::string, uint32_t > & | getFieldWeights () const |
Get map of per-field weights. | |
uint32_t | getSearchCutoff () const |
Get maximum count of examined documents. | |
uint32_t | getDistRetryCount () const |
Get distributed search retry count. | |
uint32_t | getDistRetryDelay () const |
Get distributed search retry delay. | |
const std::vector < GeoAnchorPoint_t > & | getGeoAnchorPoints () const |
Get array of geo anchor points. | |
const std::string & | getQueryComment () const |
Get comment on the query. | |
const std::string & | getSelectClause () const |
Get select clause. | |
const AttributeOverrides_t & | getAttributeOverrides () const |
Fetch all attribute overrides. |
Search query configuration object.
holds information about sorting, grouping and filtering results and the query version. Versions supported are 0x101 and 0x104 as in enum SearchCommandVersion_t.
Sphinx::SearchConfig_t::SearchConfig_t | ( | const SearchConfig_t & | from | ) |
Copy constructor
Sphinx::SearchConfig_t::SearchConfig_t | ( | SearchCommandVersion_t | cmdVer = VER_COMMAND_SEARCH_2_0_5 |
) |
Initialize with default filters
Sphinx::SearchConfig_t::~SearchConfig_t | ( | ) |
Destructor.
void Sphinx::SearchConfig_t::addAttributeOverride | ( | const std::string & | attrName, | |
AttributeType_t | attrType, | |||
uint64_t | docId, | |||
const Value_t & | value | |||
) |
Attribute value override for specified document.
attrName | name of attribute to override | |
attrType | overriden attribute type | |
docId | document id where to override the attribute | |
value | new value of the attribute |
void Sphinx::SearchConfig_t::addAttributeOverride | ( | const std::string & | attrName, | |
AttributeType_t | attrType, | |||
const std::map< uint64_t, Value_t > & | values | |||
) |
Attribute value override for specified documents.
attrName | name of attribute to override | |
attrType | overriden attribute type | |
values | values of specified attribute by document IDs |
void Sphinx::SearchConfig_t::addEnumFilter | ( | const std::string & | attrName, | |
const IntArray_t & | values, | |||
bool | excludeFlag = false | |||
) |
Adds enumeration filter to search config.
excludeFlag | invert filter (use all values except enumerated) |
void Sphinx::SearchConfig_t::addEnumFilter | ( | const std::string & | attrName, | |
const Int64Array_t & | values, | |||
bool | excludeFlag = false | |||
) |
Adds enumeration filter to search config.
excludeFlag | invert filter (use all values except enumerated) |
void Sphinx::SearchConfig_t::addFloatRangeFilter | ( | const std::string & | attrName, | |
float | minValue, | |||
float | maxValue, | |||
bool | excludeFlag = false | |||
) |
Adds float range attribute filter to search config.
excludeFlag | invert filter (use values outside spcified range) |
void Sphinx::SearchConfig_t::addRangeFilter | ( | const std::string & | attrName, | |
uint64_t | minValue, | |||
uint64_t | maxValue, | |||
bool | excludeFlag = false | |||
) |
Adds range attribute filter to search config.
excludeFlag | invert filter (use values outside spcified range) |
bool Sphinx::SearchConfig_t::getFilter | ( | int | index, | |
std::string & | attrname, | |||
bool & | exclude, | |||
float & | minValue, | |||
float & | maxValue | |||
) | const |
Get value of a float range filter added to specified position. If the filter at specified position is not of type float range, false is returned and output arguments remain unchanged.
index | Adding order of the filter (index to an array). If the index is beyond the array borders, throw ClientUsageError_t. | |
attrname | Output argument, filter attribute name is filled in. | |
exclude | Output argument, filter inversion flag is filled in. | |
minValue | Output argument, range min value is filled in. | |
maxValue | Output argument, range max value is filled in. |
ClientUsageError_t | When index is out of range. |
bool Sphinx::SearchConfig_t::getFilter | ( | int | index, | |
std::string & | attrname, | |||
bool & | exclude, | |||
uint64_t & | minValue, | |||
uint64_t & | maxValue | |||
) | const |
Get value of a integer range filter added to specified position. If the filter at specified position is not of type integer range, false is returned and output arguments remain unchanged.
index | Adding order of the filter (index to an array). If the index is beyond the array borders, throw ClientUsageError_t. | |
attrname | Output argument, filter attribute name is filled in. | |
exclude | Output argument, filter inversion flag is filled in. | |
minValue | Output argument, range min value is filled in. | |
maxValue | Output argument, range max value is filled in. |
ClientUsageError_t | When index is out of range. |
bool Sphinx::SearchConfig_t::getFilter | ( | int | index, | |
std::string & | attrname, | |||
bool & | exclude, | |||
Int64Array_t & | values | |||
) | const |
Get value of a enum filter added to specified position. If the filter at specified position is not of type enum, false is returned and output arguments remain unchanged.
index | Adding order of the filter (index to an array). If the index is beyond the array borders, throw ClientUsageError_t. | |
attrname | Output argument, filter attribute name is filled in. | |
exclude | Output argument, filter inversion flag is filled in. | |
minValue | Output argument, array of filter values is filled in. |
ClientUsageError_t | When index is out of range. |
const Filter_t* Sphinx::SearchConfig_t::getFilter | ( | int | index | ) | const |
Get filter at specified position. For internal use only.
unsigned Sphinx::SearchConfig_t::getFilterCount | ( | ) | const |
Get number of set filters.
SearchConfig_t& Sphinx::SearchConfig_t::operator= | ( | const SearchConfig_t & | from | ) |
Assignment op.
void Sphinx::SearchConfig_t::setFieldWeight | ( | const std::string & | fieldName, | |
uint32_t | weight | |||
) |
Set field weight
fieldName | Field name | |
weight | Field weight |
void Sphinx::SearchConfig_t::setGrouping | ( | GroupFunction_t | groupFunction, | |
const std::string & | groupBy = "" , |
|||
const std::string & | groupSort = "" | |||
) |
Setup search result grouping
groupFunction | fetch the match with greatest relevance per group | |
groupBy | which columns to group the result by | |
groupSort | group-by sorting clause (to sort groups in result set) |
void Sphinx::SearchConfig_t::setIndexWeight | ( | const std::string & | indexName, | |
uint32_t | weight | |||
) |
Set per-index weight.
indexName | Index name | |
weight | Index weight |
void Sphinx::SearchConfig_t::setPaging | ( | uint32_t | msgOffset, | |
uint32_t | msgLimit | |||
) |
Setup query paging
msgOffset | specifies, how many matches to skip | |
msgLimit | specifies, how many matches to fetch |
void Sphinx::SearchConfig_t::setRanking | ( | RankingMode_t | rankingMode, | |
const std::string & | rankExpr = "" | |||
) |
Set result entry ranking
rankingMode | fulltext ranking mode (default SPH_RANK_PROXIMITY_BM25) | |
rankExpr | ranking expression for SPH_RANK_EXPR |
void Sphinx::SearchConfig_t::setRetries | ( | uint32_t | distRetryCount, | |
uint32_t | distRetryDelay | |||
) |
Set distributed search retries
distRetryCount | distributed search retry count | |
distRetryDelay | distributed search retry delay |
void Sphinx::SearchConfig_t::setSelectClause | ( | const std::string & | selectClause | ) |
Select columns to fetch in SQL-like select syntax. Available aggregation functions are MIN, MAX, SUM, AVG. AS is required
void Sphinx::SearchConfig_t::setSorting | ( | SortMode_t | sortMode, | |
const std::string & | sortBy = "" | |||
) |
Setup result entry sorting
sortMode | result sorting mode | |
sortBy | which columns or expression to sort the result by |