Skip to content

Commit

Permalink
SmartSearch: search only along active resources
Browse files Browse the repository at this point in the history
  • Loading branch information
zozlak committed Feb 23, 2024
1 parent de7e407 commit a0f6a43
Showing 1 changed file with 24 additions and 13 deletions.
37 changes: 24 additions & 13 deletions src/acdhOeaw/arche/lib/SmartSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -296,16 +296,22 @@ public function search(string $phrase, string $language = '',
$inBinaryF = $inBinary ? "" : "AND ss.id IS NULL";
$query .= "
search1 AS (
SELECT
coalesce(ss.id, m.id) AS id,
-1::bigint AS ftsid,
CASE
WHEN m.property IS NOT NULL THEN m.property
ELSE 'BINARY'
END AS property,
1.0 AS weight_m,
null::text AS link_property
FROM $qp->query $inBinaryF $propsFilter
SELECT *
FROM
resources r
JOIN (
SELECT
coalesce(ss.id, m.id) AS id,
-1::bigint AS ftsid,
CASE
WHEN m.property IS NOT NULL THEN m.property
ELSE 'BINARY'
END AS property,
1.0 AS weight_m,
null::text AS link_property
FROM $qp->query $inBinaryF $propsFilter
) USING (id)
WHERE r.state = 'active'
)
";
$param = array_merge($param, $qp->param, $propsParam);
Expand All @@ -319,7 +325,10 @@ public function search(string $phrase, string $language = '',
null::text AS property,
1.0 AS weight_m,
null::text AS link_property
FROM filters
FROM
resources
JOIN filters USING (id)
WHERE state = 'active'
)
";
$curTab = 'search1';
Expand Down Expand Up @@ -349,10 +358,12 @@ public function search(string $phrase, string $language = '',
CASE WHEN raw = ? THEN ? ELSE 1.0 END * CASE WHEN $langMatch THEN ? ELSE 1.0 END AS weight_m,
null::text AS link_property
FROM
full_text_search f
resources r
JOIN full_text_search f USING (id)
LEFT JOIN metadata sm using (mid)
WHERE
websearch_to_tsquery('simple', ?) @@ segments
r.state = 'active'
AND websearch_to_tsquery('simple', ?) @@ segments
$inBinaryF
$propsFilter
)
Expand Down

0 comments on commit a0f6a43

Please sign in to comment.