Skip to content

Commit

Permalink
Add another query to remove blastdb instead of only blast database
Browse files Browse the repository at this point in the history
  • Loading branch information
almasaeed2010 committed Apr 20, 2018
1 parent 48d9ce2 commit ef9e252
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions includes/Elasticsearch/ESInstance.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public function setWebsiteSearchParams(
$query = [
"bool" => [
"must" => $queries,
"filter" => []
],
];

Expand Down
47 changes: 47 additions & 0 deletions tripal_elasticsearch.install
Original file line number Diff line number Diff line change
Expand Up @@ -426,3 +426,50 @@ function tripal_elasticsearch_update_7210() {
throw $exception;
}
}


/**
* Remove blastdb content type from website index.
*
* @throws \Exception
*/
function tripal_elasticsearch_update_7211() {
try {
$es = new ESInstance();
$count = $es->setWebsiteSearchParams('*', 'blastdb', 'website')
->count();
$client = $es->client;

if ($count === 0) {
print "No blastdb content was found\n";
return;
}

for ($i = 0; $i < $count; $i += 100) {
$results = $es->setWebsiteSearchParams('*', 'blastdb', 'website', 'website', [
$i,
100,
])->search(FALSE);
foreach ($results as $result) {
$client->deleteByQuery([
'index' => 'website',
'type' => 'website',
'body' => [
'query' => [
'match' => [
'nid' => $result['nid'],
],
],
],
]);
}
}

print "Successfully removed all blastdb nodes from website index.\n";
} catch (Exception $exception) {
print "ERROR: failed to remove blastdb nodes from website index due to the following exception\n";
print $exception->getMessage();

throw $exception;
}
}

0 comments on commit ef9e252

Please sign in to comment.