Reputation: 1
This is my code. I want to display the author name with his book. I had uploaded two files to Solr (book, author) and there is column share between the two file (authid
on another file and oAuth on book file).
I don't know how can do this process in Solarium?
<?php
require(__DIR__.'/init.php');
htmlHeader();
// create a client instance
$client = new Solarium\Client($config);
// get a select query instance
$query = $client->createSelect();
//be sure to validate and clean your variables
$val1 = htmlentities($_GET['searchSolr']);
//then you can use them in a PHP function.
$query->createFilterQuery('search')->setQuery(('bk:'). $val1);
// this executes the query and returns the result
$resultset = $client->select($query);
// display the total number of documents found by solr
echo 'عدد نتائج البحث: '.$resultset->getNumFound();
// show documents using the resultset iterator
foreach ($resultset as $document) {
echo '<hr/><table>';
echo '<tr><th>اسم الكتاب:</th><td>' . $document->bk[0] . '</td></tr>';
echo '<tr><th>رقم الكتاب:</th><td>' . $document->bkid[0] . '</td></tr>';
echo '</table>';
}
htmlFooter();
Upvotes: 0
Views: 252
Reputation: 52882
Solr can't perform regular joins, the only supported functionality for regular joins is to use one side of the join to filter the other side - i.e. the same as an INNER JOIN. In your case you want information from both sides (the author name and the book title), which just isn't possible with the "join" functionality in Solr.
If you're running Solr in its cloud mode, using a streaming expression can be a solution, but the preferred way to solve this is to just add the name of the author to the book document itself. That way it's part of the data you need for a book (and an author's name usually doesn't change often, so performing updates will be very manageable).
Upvotes: 0