Created
June 20, 2016 11:43
-
-
Save algotrader-dotcom/364a594a8a018cad5a860c679cb1430f to your computer and use it in GitHub Desktop.
A script to help evaluate search problems, using drush.
This file contains hidden or 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
drush ev ' | |
$keys = "*:*"; | |
$rows = 5; | |
$fields = "score,label,id,entity_id,site,bundle,ss_type,tm_title,content"; // * == All fields | |
$facets = explode(",", "site,hash,bundle,access__all,entity_type,index_id,ss_language,is_status,ss_type"); | |
// Get Solr. | |
$solr = false; | |
if (function_exists("apachesolr_get_solr")) { | |
// apachesolr.module | |
$solr = apachesolr_get_solr(); | |
} | |
elseif (function_exists("search_api_server_load")) { | |
// search_api_solr.module | |
$servers = search_api_server_load_multiple(false); | |
foreach ($servers as $server_id => $server_data) { | |
break; | |
} | |
$solr = search_api_server_load($server_id)->getSolrConnection(); | |
} | |
if (! $solr) { | |
echo "No Solr instance found."; | |
} | |
echo "\n== Summary of core status: =====\n"; | |
$tmp = $solr->getStatsSummary(); print_r($tmp); | |
$params = array("q" => $keys, "rows" => $rows, "defType" => "edismax", "fl" => $fields, "facet" => "true", "facet.missing" => "true", "json.nl" => "map", "facet.field" => $facets); | |
echo "\n== Result of the query " . json_encode($params) .": =====\n"; | |
$response = $solr->makeServletRequest("select", $params); | |
print_r($response->response); | |
echo "\n== Document counts by some important fields: =====\n"; | |
print_r($response->facet_counts); | |
echo "\n== Listing of available fields: =====\n"; | |
$tmp = $solr->getLuke(); $fields = array_keys((array)$tmp->fields); asort($fields); echo implode("\n", $fields); | |
' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment