Skip to content

Commit

Permalink
SmartSearch::getSearchFacets(): report match property and link proper…
Browse files Browse the repository at this point in the history
…ty as last facets
  • Loading branch information
zozlak committed Apr 11, 2024
1 parent 71f1862 commit 8cab56b
Showing 1 changed file with 40 additions and 40 deletions.
80 changes: 40 additions & 40 deletions src/acdhOeaw/arche/lib/SmartSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -658,46 +658,6 @@ public function getSearchFacets(string $prefLang = ''): array {
$stats = [];
$t = microtime(true);

// MATCH PROPERTY
$query = $this->pdo->query("
SELECT
property AS value,
property AS label,
count(DISTINCT id) AS count
FROM " . self::TEMPTABNAME . "
WHERE property IS NOT NULL
GROUP BY 1
ORDER BY 2 DESC
");
$values = $query->fetchAll(PDO::FETCH_OBJ);
if (count($values) > 0) {
$stats['property'] = [
'continuous' => false,
'values' => $values,
];
}

// LINK PROPERTY
if ($this->linkNamedEntities()) {
$query = $this->pdo->query("
SELECT
link_property AS value,
link_property AS label,
count(DISTINCT id) AS count
FROM " . self::TEMPTABNAME . "
WHERE link_property IS NOT NULL
GROUP BY 1
ORDER BY 2 DESC
");
$values = $query->fetchAll(PDO::FETCH_OBJ);
if (count($values) > 0) {
$stats['linkProperty'] = [
'continuous' => false,
'values' => $values,
];
}
}

// FACETS
$objectFacets = [];
$valueFacets = [];
Expand Down Expand Up @@ -843,6 +803,46 @@ public function getSearchFacets(string $prefLang = ''): array {
];
}

// MATCH PROPERTY
$query = $this->pdo->query("
SELECT
property AS value,
property AS label,
count(DISTINCT id) AS count
FROM " . self::TEMPTABNAME . "
WHERE property IS NOT NULL
GROUP BY 1
ORDER BY 2 DESC
");
$values = $query->fetchAll(PDO::FETCH_OBJ);
if (count($values) > 0) {
$stats['property'] = [
'continuous' => false,
'values' => $values,
];
}

// LINK PROPERTY
if ($this->linkNamedEntities()) {
$query = $this->pdo->query("
SELECT
link_property AS value,
link_property AS label,
count(DISTINCT id) AS count
FROM " . self::TEMPTABNAME . "
WHERE link_property IS NOT NULL
GROUP BY 1
ORDER BY 2 DESC
");
$values = $query->fetchAll(PDO::FETCH_OBJ);
if (count($values) > 0) {
$stats['linkProperty'] = [
'continuous' => false,
'values' => $values,
];
}
}

$this->queryLog?->debug('FACETS STATS time ' . (microtime(true) - $t));
return $stats;
}
Expand Down

0 comments on commit 8cab56b

Please sign in to comment.