Skip to content

Commit 50d9b0f

Browse files
Merge pull request #1024 from openml/ES_fix
ES robustness bandaid
2 parents 19731a0 + 7203d29 commit 50d9b0f

1 file changed

Lines changed: 26 additions & 23 deletions

File tree

openml_OS/libraries/ElasticSearch.php

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ private function build_study($d) {
761761
'uploader_id' => $d->creator,
762762
'uploader' => array_key_exists($d->creator, $this->user_names) ? $this->user_names[$d->creator] : 'Unknown',
763763
'visibility' => $d->visibility,
764-
'type' => $d->main_entity_type,
764+
'study_type' => $d->main_entity_type,
765765
'legacy' => $d->legacy,
766766
'suggest' => array(
767767
'input' => array($d->name, $d->description . ' '),
@@ -1064,10 +1064,12 @@ private function fetch_classes($id = false) {
10641064

10651065
private function fetch_runfiles($min, $max) {
10661066
$index = array();
1067-
foreach ($this->db->query('SELECT source, field, name, format, file_id from runfile where source >= ' . $min . ' and source < ' . $max) as $r) {
1068-
$index[$r->source][$r->field]['url'] = BASE_URL . 'data/download/' . $r->file_id . '/' . $r->name;
1069-
$index[$r->source][$r->field]['format'] = $r->format;
1070-
}
1067+
$runfiles = $this->db->query('SELECT source, field, name, format, file_id from runfile where source >= ' . $min . ' and source < ' . $max);
1068+
if ($runfiles)
1069+
foreach ($runfiles as $r) {
1070+
$index[$r->source][$r->field]['url'] = BASE_URL . 'data/download/' . $r->file_id . '/' . $r->name;
1071+
$index[$r->source][$r->field]['format'] = $r->format;
1072+
}
10711073
return $index;
10721074
}
10731075

@@ -1439,16 +1441,16 @@ private function build_task_type($d) {
14391441
);
14401442

14411443
$inputs = $this->db->query('SELECT name, type, description, io, requirement FROM task_type_inout where ttid=' . $d->ttid);
1442-
1443-
foreach ($inputs as $i) {
1444-
$new_data['input'][] = array(
1445-
'name' => $i->name,
1446-
'type' => $i->type,
1447-
'description' => $i->description,
1448-
'io' => $i->io,
1449-
'requirement' => $i->requirement
1450-
);
1451-
}
1444+
if ($inputs)
1445+
foreach ($inputs as $i) {
1446+
$new_data['input'][] = array(
1447+
'name' => $i->name,
1448+
'type' => $i->type,
1449+
'description' => $i->description,
1450+
'io' => $i->io,
1451+
'requirement' => $i->requirement
1452+
);
1453+
}
14521454
return $new_data;
14531455
}
14541456

@@ -1767,15 +1769,16 @@ public function index_single_dataset($id) {
17671769
if ($id and ! $datasets)
17681770
return 'Error: data set ' . $id . ' is unknown';
17691771

1770-
foreach ($datasets as $d) {
1771-
$params['body'][] = array(
1772-
'index' => array(
1773-
'_id' => $d->did
1774-
)
1775-
);
1772+
if ($datasets)
1773+
foreach ($datasets as $d) {
1774+
$params['body'][] = array(
1775+
'index' => array(
1776+
'_id' => $d->did
1777+
)
1778+
);
17761779

1777-
$params['body'][] = $this->build_data($d);
1778-
}
1780+
$params['body'][] = $this->build_data($d);
1781+
}
17791782

17801783
$responses = $this->client->bulk($params);
17811784

0 commit comments

Comments
 (0)