15 @date_default_timezone_set(@date_default_timezone_get());
17 require_once
'hce_cli_api.inc.php';
18 require_once
'hce_sphinx_api.inc.php';
20 defined(
'LOG_MODE_JSON') or define('LOG_MODE_JSON', 3);
21 defined('RESPONSE_TIMEOUT_DEFAULT') or define('RESPONSE_TIMEOUT_DEFAULT', 5000);
23 if(php_sapi_name()!=='cli' || !
defined('STDIN')){
24 echo
'Only cli execution mode supported'.PHP_EOL;
32 ' [--q=query_string|"`query_string`">] [--f=<filters>] [--s=<sorting>] [--n=<max_queries_number>] [--r=<max_results>] [--d=<request_delay_ms>]'.
33 ' [--l=<log_mode{0-no,1-result,2-params,3-json,4-result+object}>]'.
34 ' [--t=<response_timeout_ms, '.RESPONSE_TIMEOUT_DEFAULT.
' default>] [--host=<router_host>] [--port=<router_port>] [--cid=<client_id>]'.
35 ' [--route=<route string include of node names list comma separated>]'.
36 ' [--sphinx_timeout=<sphinx_searchd_timeout_ms '.HCE_SPHINX_SEARCH_FIELD_TIMEOUT_DEFAULT.
' default>]'.PHP_EOL.
37 'filters - list of filter items delimited by semicolon. Filter item: "type{integer},field_name{string},value1,...,valueN{integers},exclude{0,1}"'.PHP_EOL.
38 'sort - list of sort parameters delimited by comma. Format: "algorithm{integer},field1[,...,fieldN]{strings},order{1,2}"'.PHP_EOL;
59 if(isset(
$args[
'f'])){
60 $filters1=explode(
';',
$args[
'f']);
61 foreach($filters1 as $filter1){
62 $filter1=explode(
',', $filter1);
63 if(count($filter1)>2){
64 if($filter1[0]==0 || $filter1[0]==1 || $filter1[0]==2 || $filter1[0]==3){
71 for($i=2; $i<count($filter1)-1; $i++){
72 $values[]=trim($filter1[$i]);
75 HCE_SPHINX_SEARCH_FIELD_FILTER_ATTRIB=>trim($filter1[1]),
76 HCE_SPHINX_SEARCH_FIELD_FILTER_VALUES=>$values,
77 HCE_SPHINX_SEARCH_FIELD_FILTER_EXCLUDE=>trim($filter1[count($filter1)-1])
80 echo
'Wrong number of filter parameters in filter item type:'.$filter1[0].
', item ignored'.PHP_EOL;
87 if(isset(
$args[
's'])){
91 HCE_SPHINX_SEARCH_FIELD_ORDER_FIELDS=>array_slice(
$order, 1, count(
$order)-2),
92 HCE_SPHINX_SEARCH_FIELD_ORDER_BY=>(
$order[count(
$order)-1]==
'0' ? HCE_SPHINX_SEARCH_FIELD_ORDER_BY_ASC : HCE_SPHINX_SEARCH_FIELD_ORDER_BY_DESC)
95 echo
'Wrong number of sort parameters, sort option ignored, default settings applied'.PHP_EOL;
102 ', router_port:'.$Connection_port.
', client_id:"'.
$Client_Identity.
'"'.PHP_EOL.PHP_EOL;
105 $ret_arrays_mask=(HCE_SPHINX_SEARCH_RET_TYPE_MI_INFO | HCE_SPHINX_SEARCH_RET_TYPE_RI_INFO | HCE_SPHINX_SEARCH_RET_TYPE_AT_INFO | HCE_SPHINX_SEARCH_RET_TYPE_WI_INFO).
'';
108 HCE_SPHINX_SEARCH_FIELD_FILTERS=>
$filters,
109 HCE_SPHINX_SEARCH_FIELD_ORDER=>
$order,
115 echo
'Request json:'.PHP_EOL.$Request_body.PHP_EOL.PHP_EOL;