with solr php client you can get results from solr.
if ($results)
{
$total = (int) $results->response->numFound;
$start = min(1, $total);
$end = min($limit, $total);
echo "Visar: " . $start . " - " . $end . " av " . $total . "<br />";
// iterate result documents
foreach ($results->response->docs as $doc)
{
<<<<<<<<HERE >>>>>>>>
// iterate document fields / values
foreach ($doc as $field => $value)
{
echo htmlspecialchars($field, ENT_NOQUOTES, 'utf-8') . "<br />";
echo htmlspecialchars($value, ENT_NOQUOTES, 'utf-8');
//echo $doc['threads.title'] . "<br/>";
}
}
}
i want to get specific the field names (threads.id and posts.id) in <<<<<<< HERE >>>>>>> to be able to get related data from thread and user from mysql database. but i dont know how to access it. i tried $doc['thread_id'] but it didnt work. $doc is a solr object.
when i in <<<<<<< HERE >>>>>>> put print_r($doc) it showed:
Apache_Solr_Document Object ( [_documentBoost:protected] => [_fields:protected] => Array ( [posts.id] => 18 [posts.body] => windows [posts.thread_id] => 18 [threads.title] => windows [id] => 5dc387c9-0039-4b3d-b234-98eb861c1316 ) [_fieldBoosts:protected] => Array ( [posts.id] => [posts.body] => [posts.thread_id] => [threads.title] => [id] => ) ) Apache_Solr_Document Object ( [_documentBoost:protected] => [_fields:protected] => Array ( [posts.id] => 19 [posts.body] => windows [posts.thread_id] => 19 [threads.title] => windows [id] => f8009b81-6c86-4eba-9240-c112244d21dc ) [_fieldBoosts:protected] => Array ( [posts.id] => [posts.body] => [posts.thread_id] => [threads.title] => [id] => ) ) Apache_Solr_Document Object ( [_documentBoost:protected] => [_fields:protected] => Array ( [posts.id] => 20 [posts.body] => windows [posts.thread_id] => 20 [threads.title] => NEEEEEEEEEJ [id] => c59b9035-ea14-4022-b997-9de810f278a6 ) [_fieldBoosts:protected] => Array ( [posts.id] => [posts.body] => [posts.thread_id] => [threads.title] => [id] => ) ) Apache_Solr_Document Object ( [_documentBoost:protected] => [_fields:protected] => Array ( [posts.id] => 3 [posts.body] => windows vista är bäst [posts.thread_id] => 3 [threads.title] => jakob [id] => 889b9e7b-c444-4c56-90bf-fbb672b0018c ) [_fieldBoosts:protected] => Array ( [posts.id] => [posts.body] => [posts.thread_id] => [threads.title] => [id] => ) )