1--TEST-- 2SolrClient::getByIds() - Testing Real Time Get by ids 3--SKIPIF-- 4<?php 5include 'skip.if.server_not_configured.inc'; 6?> 7--FILE-- 8<?php 9 10require_once "bootstrap.inc"; 11 12$options = array 13( 14 'hostname' => SOLR_SERVER_HOSTNAME, 15 'login' => SOLR_SERVER_USERNAME, 16 'password' => SOLR_SERVER_PASSWORD, 17 'port' => SOLR_SERVER_PORT, 18 'path' => SOLR_SERVER_PATH 19); 20 21$client = new SolrClient($options); 22$response = $client->getByIds(['GB18030TEST', '6H500F0']); 23var_dump(isset($response->getArrayResponse()['response']['docs'])) . PHP_EOL; 24var_dump($response->getResponse()->response->start) . PHP_EOL; 25try { 26 $response = $client->getByIds(['GB18030TEST', '']); 27} catch (Exception $e) { 28 printf("Exception %d: %s", $e->getCode(), $e->getMessage()); 29} 30echo PHP_EOL.PHP_EOL; 31// make sure request was reset 32$response = $client->getByIds(['GB18030TEST']); 33$headers = explode(PHP_EOL, trim($response->getRawRequestHeaders())); 34 35$headers = array_filter($headers, function($header) { 36 return strstr($header, 'collection1') !== false; 37}); 38 39print_r(implode(PHP_EOL, $headers).PHP_EOL); 40 41echo PHP_EOL; 42try { 43 $response = $client->getByIds([]); 44} catch (Exception $e) { 45 printf("Exception %d: %s", $e->getCode(), $e->getMessage()); 46} 47?> 48--EXPECTF-- 49bool(true) 50int(0) 51Exception 4000: Invalid id at position 1 52 53GET /solr/collection1/get/?version=2.2&indent=on&wt=xml&ids=GB18030TEST HTTP/1.1 54 55Exception 4000: Invalid parameter: at least 1 ID is required. Passed an empty array. 56