我真的很想为自定义solr打印完整查询。
我使用此代码从solr获取结果:
示例:
$solr = apachesolr_get_solr('name_of_solr');
if($solr->ping()) {
$params = array(
'q' => '*',
'start' => 0,
'rows' => 20,
'fl' => 'entity_id',
);
$query = new SolrBaseQuery('apachesolr', $solr, $params, '');
$query->addParam('sort', 'ss_published_date desc');
$query->addFilter('im_field_section', $sc_id);
}
$response = $query->search();
我想通过以下方式获取完整的查询或网址
dpm($query);//Getting object..
预期结果:
http://11.11.111.111:8983/solr/tod/select?fl=entity_id&fq=im_field_section:%20174&indent=on&q=*:*&rows=20&sort=ss_published_date%20desc&start=0&wt=json
答案 0 :(得分:0)
我们可以通过从响应对象中读取数组键 [request] 来获取完整的请求URL:
drupal_set_message(print_r($response, TRUE));
# output :
stdClass Object ( [request] => GET /solr/tod/select?start=0&rows=1&fq=sm_outlet_relations%3A12702&fq=im_field_section%3A44&q=%2A&fl=entity_id&sort=ss_published_date%20desc&wt=json&json.nl=map HTTP/1.0 User-Agent: Drupal (+http://drupal.org/) Host: my_host [data] => {"response":{"numFound":1,"start":0,"docs":[{"entity_id":582143}]}} [protocol] => HTTP/1.1 [status_message] => OK [headers] => Array ( [content-type] => text/plain;charset=utf-8 [content-length] => 68 ) [code] => 200 [response] => stdClass Object ( [numFound] => 1 [start] => 0 [docs] => Array ( [0] => stdClass Object ( [entity_id] => 582143 ) ) ) )
或者只是:
dpm($response->request);
# output :
GET /solr/tod/select?start=0&rows=1&fq=sm_outlet_relations%3A12702&fq=im_field_section%3A44&q=%2A&fl=entity_id&sort=ss_published_date%20desc&wt=json&json.nl=map HTTP/1.0 User-Agent: Drupal (+http://drupal.org/) Host: my_host
答案 1 :(得分:0)
如果您将solr查询添加到echoParams,您将获得有关查询的更多详细信息,然后可以将其串联以构建原始查询字符串。