-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow to run solr-indexing without an existing collection #289: fixi…
…ng the issue around 'validation' Solr instance
- Loading branch information
Showing
11 changed files
with
166 additions
and
30 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
# calculate and store the aggregated number of instances and records | ||
# for issue types, categories and paths within each groups | ||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
# | ||
|
||
log() { | ||
echo "$(date +'%F %T')> $1" | ||
} | ||
|
||
OUTPUT_DIR=$1 | ||
NAME=$2 | ||
HAS_GROUP_PARAM=$3 | ||
SOLR_FOR_SCORES_URL=$4 | ||
|
||
log "OUTPUT_DIR: ${OUTPUT_DIR}" | ||
|
||
if [[ -f $(pwd)/solr-functions ]]; then | ||
. ./solr-functions | ||
else | ||
. ./../../solr-functions | ||
fi | ||
|
||
if [[ "${SOLR_FOR_SCORES_URL}" != "" ]]; then | ||
SOLR_HOST=$(extract_host $SOLR_FOR_SCORES_URL) | ||
SOLR_CORE=$(extract_core $SOLR_FOR_SCORES_URL) | ||
else | ||
SOLR_CORE=${NAME}_validation | ||
fi | ||
log "using Solr at ${SOLR_HOST}/${SOLR_CORE}" | ||
log "create Solr core" | ||
|
||
CORE_EXISTS=$(check_core $SOLR_CORE) | ||
log "$SOLR_CORE exists: $CORE_EXISTS" | ||
if [[ $CORE_EXISTS != 1 ]]; then | ||
echo "Create Solr core '$SOLR_CORE'" | ||
create_core $SOLR_CORE | ||
prepare_schema $SOLR_CORE | ||
else | ||
purge_core $SOLR_CORE | ||
fi | ||
|
||
log "populate Solr core" | ||
|
||
if [[ "${HAS_GROUP_PARAM}" == "0" ]]; then | ||
# index id-groupid.csv and issue-details.csv | ||
php scripts/sqlite/validation-result-indexer-simple.php ${OUTPUT_DIR} ${SOLR_HOST} ${SOLR_CORE} | ||
else | ||
# index id-groupid.csv and issue-details.csv | ||
php scripts/sqlite/validation-result-indexer-grouped.php ${OUTPUT_DIR} ${SOLR_HOST} ${SOLR_CORE} | ||
fi | ||
|
||
optimize_core $SOLR_CORE |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
define('LN', "\n"); | ||
define('CMD', "curl -X POST -H 'Content-Type: application/json' 'http://localhost:8983/solr/%s/update' --data-binary '%s'"); | ||
|
||
function index($records) { | ||
global $solrUrl; | ||
|
||
$ch = curl_init($solrUrl); | ||
curl_setopt($ch, CURLOPT_POST, 1); | ||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($records)); | ||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | ||
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); | ||
$result = curl_exec($ch); | ||
curl_close($ch); | ||
// print_r ($result); | ||
} | ||
|
||
function processIssueDetails($dir) { | ||
$fileDetails = $dir . 'issue-details.csv'; | ||
echo 'fileDetails: ', $fileDetails, "\n"; | ||
$handle = fopen($fileDetails, "r"); | ||
if ($handle) { | ||
$i = 0; | ||
$records = []; | ||
while (($line = fgets($handle)) != false) { | ||
$values = str_getcsv($line); | ||
$id = $values[0]; | ||
if ($id != 'recordId') { | ||
if (++$i % 100000 == 0) | ||
echo $i, LN; | ||
$record = (object)['id' => $id, 'errorId_is' => []]; | ||
$pairs = explode(';', $values[1]); | ||
foreach ($pairs as $pair) { | ||
list($eid, $iid) = explode(':', $pair); | ||
$record->errorId_is[] = (int) $eid; | ||
} | ||
$records[] = $record; | ||
if (count($records) == 10000) { | ||
index($records); | ||
$records = []; | ||
} | ||
} | ||
} | ||
|
||
index($records); | ||
index((object)["commit" => (object)[]]); | ||
fclose($handle); | ||
} | ||
} | ||
|
||
$dir = $argv[1]; | ||
$host = $argv[2]; | ||
$core = $argv[3]; | ||
|
||
if (preg_match('/[^\/]$/', $dir)) | ||
$dir .= '/'; | ||
|
||
$solrUrl = sprintf('%s/solr/%s/update', $host, $core); | ||
|
||
processIssueDetails($dir); | ||
|
||
echo "indexing is DONE\n"; | ||
exit(); |
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
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
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
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