Commit 47b42f7b authored by Bas de Nooijer's avatar Bas de Nooijer

Added debug component example

parent fcb9bf90
<?php
require('init.php');
htmlHeader();
// create a client instance
$client = new Solarium_Client($config);
// get a select query instance
$query = $client->createSelect();
$query->setQuery('ipod');
// add debug settings
$debug = $query->getDebug();
$debug->setExplainOther('id:MA*');
// this executes the query and returns the result
$resultset = $client->select($query);
$debugResult = $resultset->getDebug();
// display the debug results
echo '<h1>Debug data</h1>';
echo 'Querystring: ' . $debugResult->getQueryString() . '<br/>';
echo 'Parsed query: ' . $debugResult->getParsedQuery() . '<br/>';
echo 'Query parser: ' . $debugResult->getQueryParser() . '<br/>';
echo 'Other query: ' . $debugResult->getOtherQuery() . '<br/>';
echo '<h2>Explain data</h2>';
foreach ($debugResult->getExplain() as $key => $explanation) {
echo '<h3>Document key: ' . $key . '</h3>';
echo 'Value: ' . $explanation->getValue() . '<br/>';
echo 'Match: ' . (($explanation->getMatch() == true) ? 'true' : 'false') . '<br/>';
echo 'Description: ' . $explanation->getDescription() . '<br/>';
echo '<h4>Details</h4>';
foreach ($explanation AS $detail) {
echo 'Value: ' . $detail->getValue() . '<br/>';
echo 'Match: ' . (($detail->getMatch() == true) ? 'true' : 'false') . '<br/>';
echo 'Description: ' . $detail->getDescription() . '<br/>';
echo '<hr/>';
}
}
echo '<h2>ExplainOther data</h2>';
foreach ($debugResult->getExplainOther() as $key => $explanation) {
echo '<h3>Document key: ' . $key . '</h3>';
echo 'Value: ' . $explanation->getValue() . '<br/>';
echo 'Match: ' . (($explanation->getMatch() == true) ? 'true' : 'false') . '<br/>';
echo 'Description: ' . $explanation->getDescription() . '<br/>';
echo '<h4>Details</h4>';
foreach ($explanation AS $detail) {
echo 'Value: ' . $detail->getValue() . '<br/>';
echo 'Match: ' . (($detail->getMatch() == true) ? 'true' : 'false') . '<br/>';
echo 'Description: ' . $detail->getDescription() . '<br/>';
echo '<hr/>';
}
}
echo '<h2>Timings (in ms)</h2>';
echo 'Total time: ' . $debugResult->getTiming()->getTime() . '<br/>';
echo '<h3>Phases</h3>';
foreach ($debugResult->getTiming()->getPhases() as $phaseName => $phaseData) {
echo '<h4>' . $phaseName . '</h4>';
foreach ($phaseData as $class => $time) {
echo $class . ': ' . $time . '<br/>';
}
echo '<hr/>';
}
htmlFooter();
\ No newline at end of file
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,7 @@
<li><a href="2.1.5.8-distributed-search.php">2.1.5.8 Distributed search (sharding)</a></li> <li><a href="2.1.5.8-distributed-search.php">2.1.5.8 Distributed search (sharding)</a></li>
<li><a href="2.1.5.9-spellcheck.php">2.1.5.9 Spellcheck</a></li> <li><a href="2.1.5.9-spellcheck.php">2.1.5.9 Spellcheck</a></li>
<li><a href="2.1.5.10-stats.php">2.1.5.10 Stats</a></li> <li><a href="2.1.5.10-stats.php">2.1.5.10 Stats</a></li>
<li><a href="2.1.5.11-debug.php">2.1.5.11 Debug (DebugQuery)</a></li>
</ul> </ul>
<li><a href="2.1.6-helper-functions.php">2.1.6 Helper functions</a></li> <li><a href="2.1.6-helper-functions.php">2.1.6 Helper functions</a></li>
<li><a href="2.1.7-query-reuse.php">2.1.7 Query re-use</a></li> <li><a href="2.1.7-query-reuse.php">2.1.7 Query re-use</a></li>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment