diff --git a/includes/Elasticsearch/ESInstance.php b/includes/Elasticsearch/ESInstance.php
index a36d97a9..f9f7fdab 100644
--- a/includes/Elasticsearch/ESInstance.php
+++ b/includes/Elasticsearch/ESInstance.php
@@ -100,10 +100,10 @@ public function setWebsiteSearchParams(
$queries = [];
$queries[] = [
- "query_string" => [
- "default_field" => "content",
- "query" => $this->sanitizeQuery($search_terms),
- "default_operator" => "AND",
+ 'query_string' => [
+ 'default_field' => 'content',
+ 'query' => $this->sanitizeQuery($search_terms),
+ 'default_operator' => 'AND',
],
];
@@ -112,42 +112,41 @@ public function setWebsiteSearchParams(
if (in_array('website', $indices) && !$force_entities_only) {
$queries[1]['query_string'] = [
- "default_field" => "type",
- "query" => '"' . $node_type . '"',
- "default_operator" => "AND",
+ 'default_field' => 'type',
+ 'query' => '"' . $node_type . '"',
+ 'default_operator' => 'AND',
];
}
if (in_array('entities', $indices)) {
$queries[1]['query_string'] = [
- "default_field" => "bundle_label",
- "query" => '"' . $node_type . '"',
- "default_operator" => "AND",
+ 'default_field' => 'bundle_label',
+ 'query' => '"' . $node_type . '"',
+ 'default_operator' => 'AND',
];
}
if (in_array('entities', $indices) && in_array('website', $indices) && !$force_entities_only) {
$queries[1]['query_string'] = [
- "fields" => ["type", "bundle_label"],
- "query" => '"' . $node_type . '"', // Gene or mRNA (feature,Gene)
- "default_operator" => "AND",
+ 'fields' => ['type', 'bundle_label'],
+ 'query' => '"' . $node_type . '"', // Gene or mRNA (feature,Gene)
+ 'default_operator' => 'AND',
];
}
}
$query = [
- "bool" => [
- "must" => $queries,
- "filter" => []
+ 'bool' => [
+ 'must' => $queries,
],
];
$highlight = [
- "pre_tags" => [""],
- "post_tags" => [""],
- "fields" => [
- "content" => [
- "fragment_size" => 150,
+ 'pre_tags' => [''],
+ 'post_tags' => [''],
+ 'fields' => [
+ 'content' => [
+ 'fragment_size' => 150,
],
],
];
@@ -302,14 +301,14 @@ public function setIndexParams($index_name, $shards = 5, $replicas = 0,
* @return array
* @throws \Exception
*/
- public function search($return_source = false) {
+ public function search($return_source = FALSE) {
if (empty($this->searchParams)) {
throw new Exception('Please build search parameters before attempting to search.');
}
$hits = $this->client->search($this->searchParams);
- if($return_source) {
+ if ($return_source) {
return $hits;
}
diff --git a/includes/Jobs/EntitiesIndexJob.php b/includes/Jobs/EntitiesIndexJob.php
index facafeff..dfdce269 100644
--- a/includes/Jobs/EntitiesIndexJob.php
+++ b/includes/Jobs/EntitiesIndexJob.php
@@ -168,9 +168,15 @@ protected function loadContent($records) {
$content = $prev_entity['_source']['content'] + $content;
}
+ // Ignore entities with empty titles
+ $title = trim($entity->title);
+ if (empty($title)) {
+ continue;
+ }
+
$all[] = (object) [
'entity_id' => $entity->id,
- 'title' => $entity->title,
+ 'title' => $title,
'bundle_label' => $record->bundle_label,
'content' => $content,
];
diff --git a/includes/Jobs/NodesIndexJob.php b/includes/Jobs/NodesIndexJob.php
index 72efe673..fb72a9e0 100644
--- a/includes/Jobs/NodesIndexJob.php
+++ b/includes/Jobs/NodesIndexJob.php
@@ -110,9 +110,15 @@ protected function loadContent($records) {
continue;
}
+ // Ignore nodes with empty titles
+ $title = trim($record->title);
+ if(empty($title)) {
+ continue;
+ }
+
$all[] = (object) [
'nid' => $record->nid,
- 'title' => $record->title,
+ 'title' => $title,
'type' => $record->type,
'content' => $this->cleanHTML($content),
];