Created
April 5, 2013 00:57
-
-
Save dmouse/5315791 to your computer and use it in GitHub Desktop.
Create nested joins in apache solr with solarium.
- This sample run with apache solr 4.x.
- The nested querys is defined by the key _query_:" ... _query_:\" ... _query_:\" ... \" \" "
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use \Solarium\Client as Client; | |
$config = array( | |
'endpoint' => array( | |
'localhost' => array( | |
'host' => '127.0.0.1', | |
'port' => 8080, | |
'path' => '/solr4/', | |
) | |
)); | |
$client = new Client($config); | |
$select = array(); | |
$select['query'] = 'bundle:a sm_field:string\ with\ spaces _query_:"{!join from=id to=parent} bundle:b _query_:\"{!join from=id to=parent} bundle:c field_boolean:true field_term:Start \"" ds_created:[2013-03-01T00:00:01Z TO 2013-03-31T23:59:59Z]'; | |
$select['fields'] = array('bundle','id'); | |
$select['start'] = 0; | |
$select['rows'] = 100; | |
$client->createSelect($select); | |
$resultset = $client->select($query); | |
echo 'NumFound: '.$resultset->getNumFound(); | |
foreach ($resultset as $document) { | |
echo '<hr/><table>'; | |
foreach($document AS $field => $value) { | |
if (is_array($value)) | |
$value = implode(', ', $value); | |
echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>'; | |
} | |
echo '</table>'; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment