diff --git a/lib/task/search/arSolrSearchTask.class.php b/lib/task/search/arSolrSearchTask.class.php
new file mode 100644
index 0000000000..09b01ce2e1
--- /dev/null
+++ b/lib/task/search/arSolrSearchTask.class.php
@@ -0,0 +1,81 @@
+.
+ */
+
+/**
+ * Populate search index.
+ */
+class arSolrSearchTask extends sfBaseTask
+{
+ public function execute($arguments = [], $options = [])
+ {
+ sfContext::createInstance($this->configuration);
+ sfConfig::add(QubitSetting::getSettingsArray());
+
+ new sfDatabaseManager($this->configuration);
+
+ $solr = new arSolrPlugin($options);
+
+ $client = $solr->getClient();
+ if (!$arguments['query']) {
+ $this->log('Please specify a search query.');
+ } else {
+ $this->runSolrQuery($client, $arguments['query']);
+ }
+ }
+
+ protected function configure()
+ {
+ $this->addArguments([
+ new sfCommandArgument('query', sfCommandArgument::OPTIONAL, 'Search query.'),
+ ]);
+
+ $this->addOptions([
+ new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', 'qubit'),
+ new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'cli'),
+ ]);
+
+ $this->namespace = 'solr';
+ $this->name = 'search';
+
+ $this->briefDescription = 'Search the search index for a result';
+ $this->detailedDescription = <<<'EOF'
+The [solr:search] task runs a search query on solr. Usage:
+ php symfony solr:search Solr connected! Solr not connected. Click init to initialize collection
"; - print_r($response); - echo '
'; - - $url = 'http://'.SOLR_SERVER_HOSTNAME.':'.SOLR_SERVER_PORT.'/solr/'.SOLR_COLLECTION.'/schema/'; - $addFieldQuery = '{"add-field": {"name": "all","stored": "false","type": "text_general","indexed": "true","multiValued": "true"}}'; - echo "{$url}
"; - $options = [ - 'http' => [ - 'method' => 'POST', - 'content' => $addFieldQuery, - 'header' => "Content-Type: application/json\r\n". - "Accept: application/json\r\n", - ], - ]; - $context = stream_context_create($options); - $result = file_get_contents($url, false, $context); - $response = json_decode($result); - echo "ADDING ALL FIELD"; - print_r($response); - echo '
'; - - $url = 'http://'.SOLR_SERVER_HOSTNAME.':'.SOLR_SERVER_PORT.'/api/collections/'.SOLR_COLLECTION.'/config/'; - $updateDefaultHandler = '{"update-requesthandler": {"name": "/select", "class": "solr.SearchHandler", "defaults": {"df": "all", "rows": 10, "echoParams": "explicit"}}}'; - $options = [ - 'http' => [ - 'method' => 'POST', - 'content' => $updateDefaultHandler, - 'header' => "Content-Type: application/json\r\n". - "Accept: application/json\r\n", - ], - ]; - $context = stream_context_create($options); - $result = file_get_contents($url, false, $context); - $response = json_decode($result); - echo "Updating default field"; - print_r($response); - echo '
'; - } - - function addToCopyField($field) - { - $url = 'http://'.SOLR_SERVER_HOSTNAME.':'.SOLR_SERVER_PORT.'/solr/'.SOLR_COLLECTION.'/schema/'; - $copySourceDest = [ - 'add-copy-field' => [ - 'source' => $field, - 'dest' => ['all'], - ], - ]; - echo "{$url}
"; - echo ""; - echo json_encode($copySourceDest); - echo '
'; - $options = [ - 'http' => [ - 'method' => 'POST', - 'ignore_errors' => true, - 'content' => json_encode($copySourceDest), - 'header' => "Content-Type: application/json\r\n". - "Accept: application/json\r\n", - ], - ]; - - $context = stream_context_create($options); - $result = file_get_contents($url, false, $context); - $response = json_decode($result); - echo "SETTING {$field} TO COPY"; - print_r($response); - echo '
'; - } - - function indexData($client) - { - // Create connection - $conn = mysqli_connect(SQL_SERVER_HOSTNAME, SQL_SERVER_USER, SQL_SERVER_PASSWORD, SQL_SERVER_DB, SQL_SERVER_PORT); - - // Check connection - if ($conn->connect_error) { - exit("Connection failed: ".$conn->connect_error.'
'); - } - echo "MySQL Connected successfully!
"; - - // SQL Query string - $sql = 'select title t, archival_history ah, id, scope_and_content sc, extent_and_medium ext, acquisition aq from information_object_i18n LIMIT 1000'; - if ($result = $conn->query($sql)) { - while ($row = $result->fetch_assoc()) { - echo "${row['t']}
"; - $doc = new SolrInputDocument(); - $doc->addField('id', $row['id']); - $doc->addField('title', $row['t']); - $doc->addField('scope', $row['sc']); - $doc->addField('extent', $row['ext']); - $doc->addField('acquisition', $row['aq']); - $doc->addField('archivalHistory', $row['ah']); - $updateResponse = $client->addDocument($doc); - echo ""; - print_r($updateResponse->getResponse()); - echo '
'; - } - - // freeresultset - $result->free(); - } else { - echo "No SQL results found in information_object_i18n
"; - } - $conn->close(); - } - - function deleteData($client) - { - //This will erase the entire index - $deleteResponse = $client->deleteByQuery('*:*'); - $client->commit(); - echo ""; - print_r($deleteResponse->getResponse()); - echo '
'; - } - - function searchQuery($client, $queryText) - { - $query = new SolrQuery(); - $query->setQuery($queryText); - - $query->setStart(0); - $query->setRows(1000); - - $searchResponse = $client->query($query); - - $response = $searchResponse->getResponse()->response; - if ($response->docs) { - foreach ($response->docs as $resp) { - $title = $resp->title[0]; - $scope = $resp['scope']; - $extent = $resp['extent']; - $acquisition = $resp['acquisition']; - $history = $resp['archivalHistory']; - echo "{$history[0]}
"; - } - if (!$scope && !$extent & !$acquisition) { - continue; - } - echo "{$scope[0]}
"; - } - if ($extent) { - echo "{$extent[0]}
"; - } - if ($acquisition) { - echo "{$acquisition[0]}
"; - } - echo 'No results found
"; - } - } - ?> - - - diff --git a/solr/reset.css b/solr/reset.css deleted file mode 100644 index 38298f30e2..0000000000 --- a/solr/reset.css +++ /dev/null @@ -1,48 +0,0 @@ -/* http://meyerweb.com/eric/tools/css/reset/ -v2.0 | 20110126 -License: none (public domain) - */ - -html, body, div, span, applet, object, iframe, -h1, h2, h3, h4, h5, h6, p, blockquote, pre, -a, abbr, acronym, address, big, cite, code, -del, dfn, em, img, ins, kbd, q, s, samp, -small, strike, strong, sub, sup, tt, var, -b, u, i, center, -dl, dt, dd, ol, ul, li, -fieldset, form, label, legend, -table, caption, tbody, tfoot, thead, tr, th, td, -article, aside, canvas, details, embed, -figure, figcaption, footer, header, hgroup, -menu, nav, output, ruby, section, summary, -time, mark, audio, video { - margin: 0; - padding: 0; - border: 0; - font-size: 100%; - font: inherit; - vertical-align: baseline; -} -/* HTML5 display-role reset for older browsers */ -article, aside, details, figcaption, figure, -footer, header, hgroup, menu, nav, section { - display: block; -} -body { - line-height: 1; -} -ol, ul { - list-style: none; -} -blockquote, q { - quotes: none; -} -blockquote:before, blockquote:after, -q:before, q:after { - content: ''; - content: none; -} -table { - border-collapse: collapse; - border-spacing: 0; -} diff --git a/solr/style.css b/solr/style.css deleted file mode 100644 index 03ea53f581..0000000000 --- a/solr/style.css +++ /dev/null @@ -1,88 +0,0 @@ -.container { - font-family: 'Helvetica', 'Arial', sans-serif; - margin: 1rem; -} - -.form-container { - display: flex; - align-items: center; - justify-content: space-between; -} - -.form-row { - margin: 1rem 0; -} - -.form-label { - margin-right: 0.5rem; -} - -.form-text { - padding: 0.25rem 0.5rem; - border: 1.5px solid rgba(0, 0, 0, 0.25); - border-radius: 0.5rem; -} - -.info { - font-size: 0.75rem; - padding: 0.5rem; - background: rgba(0, 0, 0, 0.75); -} - -.info--log { - color: gray; -} - -.info--success { - color: greenyellow; -} - -.info--notice { - color: turquoise; -} - -.info--warning { - color: goldenrod; -} - -.info--error { - color: red; -} - -.info--solr-status { - position: fixed; - bottom: 1rem; - right: 1rem; -} - -.title { - font-weight: 700; - margin: 2rem 0 1rem; - font-size: 1.15rem; -} - -.text { - max-width: 30%; - line-height: 1.5; -} - -.info-container { - border: 1px solid rgba(100, 100, 100, 0.5); - border-radius: 0.25rem; - max-width: 30%; - margin: 0.5rem 0; - box-shadow: 3px 3px rgba(100, 100, 100, 0.35); -} - -.info-container__heading { - padding: 0.5rem; - background: rgba(255, 136, 0, 0.5); -} -.info-container__detail { - padding: 0.5rem; - line-height: 1.25; -} - -.info-container__detail:not(:last-of-type) { - border-bottom: 0.5px solid rgba(100, 100, 100, 0.25); -}