```
$osk = array(
'access_key' => "eOd5HGId0yGhXvC2",
'secret' => "YaNUrwAGbYMIhg1cO0cRzesHGae8P7",
'key_type' => "aliyun"
);
$opts = array(
'host' => "http://opensearch-cn-hangzhou.aliyuncs.com"
);
$pageNumber = $_REQUEST['page'] ? $_REQUEST['page'] : 1 ;
$pageSize = 10;
$client = new \CloudsearchClient($osk['access_key'], $osk['secret'], $opts, $osk['key_type']);
$query = "";
if ($title != ""){
$query .= " AND id:'".$title."'";
}
//查询条件
$search -> addFilter("sex>0", "AND");
// 过滤搜索条件前面的AND
if(substr($query, 0, 4) == " AND"){
$query = substr($query, 4);
}
// 实例化一个搜索类
$search = new \CloudsearchSearch($client);
// 添加指定搜索的应用:
$search -> addIndex("resume");
// 指定搜索关键词
$search->setQueryString($query);
// 设定搜索结果偏移量
$search -> setStartHit(($pageNumber - 1) * $pageSize);
// 设定返回的条数
$search -> setHits($pageSize);
// 指定搜索返回的格式
$search -> setFormat('json');
// 返回搜索结果
$result = $search -> search();
$infoArr = json_decode($result, true);
$data = $infoArr['result'];