Skip to content

Commit

Permalink
Simplified queries
Browse files Browse the repository at this point in the history
  • Loading branch information
davenquinn committed Oct 8, 2024
1 parent bfa01ee commit c2053e2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
2 changes: 1 addition & 1 deletion macrostrat_tileserver/vector_search/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ async def get_tile(
model_name=model_name,
linesize=linesize,
term_id=term_id,
norm_method=norm_method,
# norm_method=norm_method,
layer_name="units",
)

Expand Down
18 changes: 2 additions & 16 deletions macrostrat_tileserver/vector_search/queries/units.sql
Original file line number Diff line number Diff line change
Expand Up @@ -49,25 +49,11 @@ res AS (
AND le.model_id = term.model_id
WHERE geom IS NOT NULL
),
boundaries AS (
SELECT
term.lower_bound,
term.upper_bound
FROM term
WHERE :norm_method = 'global'
UNION ALL
SELECT
min(raw_similarity) AS lower_bound,
max(raw_similarity) AS upper_bound
FROM res
WHERE :norm_method = 'tile'
),
res2 AS (
SELECT
res.*,
-- cosine similarity between the term and the legend embedding
(raw_similarity - lower_bound) / (upper_bound - lower_bound) AS similarity
FROM res
JOIN boundaries ON true
(raw_similarity - term.lower_bound) / (term.upper_bound - term.lower_bound) AS similarity
FROM res, term
)
SELECT * FROM res2

0 comments on commit c2053e2

Please sign in to comment.