http://{url_endpoint}/?wt=json&rows=20&start=0&q=content: contentText OR title: titleText OR ur: url
- wt=json 结果将是 json 格式
- rows=20 结果将按每页 20 条记录进行分页
- start=0 页面开始显示结果
- q= 查询运行搜索(确保正确转义输入也 * 通配符以查找之前和之后的任何内容)
在 php 中使用 curl。
$solr_end_point = ''; //enter endpoint
$search_term = '';
$url_type = '';
$start = 0;
$ch = curl_init();
$query = urlencode("content:*{$search_term}* OR title:*{$search_term}* OR ur:*{$url_type}*");
curl_setopt($ch, CURLOPT_URL, "http://{$solr_end_point}/?wt=json&rows=30&start={$start}&q={$query}");
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 2);
$result = curl_exec($ch);
curl_close($ch);
print_r($result); //output result (json)
$json_result = json_decode($result,true);
print_r($json_result); //output result as an array
exit();