百度LBS云检索/存储的TAG使用
打标签可以将两张表的事情放到一张表里去做,合理的利用tag可以节省检索的工作量。
今天对百度LBS云存储的tag进行了使用测试,收获大大滴,做个简单的问题记录吧。
1、tag以空格区分,写入的时候不能超过256,检索的时候不能超过45
2、tag检索的时候是以空格分隔,切分关键词进行检索
3、tag之间是&&的形式。例如检索 “羽毛球 台球”,那么结果是tag包括“羽毛球&&台球”
4、tag为中文的时候记得需要进行url编码,否则检索结果为空
附两个测试函数:(不是我格式不好哈,排版问题就不调整了,哎!!!!)
public function CreatePoi($longitude, $latitude, $name, $tags)
{
$ret = array(
'status' => 999,
'id' => 0,
'message' => '参数错误',
);
if (empty($longitude) || empty($latitude)){
return $ret;
}
$url = $this->_url['createPoi'];
$postData = array(
'title' => $name,
'tags' => $tags,
'latitude' => $latitude,
'longitude' => $longitude,
'coord_type' => $this->_coordType,
'geotable_id' => $this->_table,
'ak' => $this->_ak,
);
$ret = $this->curlRequest($url, $postData, 'POST', 'JSON');
return $ret;
}
public function NearBySearch($longitude, $latitude, $tags)
{
$ret = array(
'status' => 999,
'id' => 0,
'message' => '参数错误',
);
if (empty($longitude) || empty($latitude)){
return $ret;
}
$geotableId = $this->_table[$type];
$url = $this->_url['nearBySearch'];
/*
检索半径可以设置
*/
if ($radius == 0){
$radius = $this->_radius;
}
$param = "?ak=$this->_ak&geotable_id=$this->_table&q=&location=$longitude,$latitude&coord_type=$this->_coordType&tags=$tags&radius=$this->_radius&sortby=distance:1";
$ret = $this->curlRequest($url.$param, array(), 'GET', 'JSON');
return $ret;
}



