Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
406 changes: 406 additions & 0 deletions src/pgstac/migrations/pgstac.0.9.8-unreleased.sql

Large diffs are not rendered by default.

4,593 changes: 4,593 additions & 0 deletions src/pgstac/migrations/pgstac.unreleased.sql

Large diffs are not rendered by default.

14 changes: 13 additions & 1 deletion src/pgstac/pgstac.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3099,6 +3099,18 @@ BEGIN
-- - -> !
processed_text := regexp_replace(processed_text, '^\s*\-([a-zA-Z0-9_]+)', '! \1', 'g'); -- -term at start
processed_text := regexp_replace(processed_text, '\s*\-([a-zA-Z0-9_]+)', ' & ! \1', 'g'); -- -term elsewhere

-- terms separated with spaces are assumed to represent an AND clause. loop through these
-- occurrences and replace them with &
LOOP
temp_text := regexp_replace(processed_text, '([a-zA-Z0-9_]+)\s+([a-zA-Z0-9_]+)(?!\s*[&|<>])', '\1 & \2', 'g');
IF temp_text = processed_text THEN
EXIT; -- No more replacements were made
END IF;
processed_text := temp_text;
END LOOP;


-- Replace placeholders back with quoted phrases if there were any
IF array_length(quote_array, 1) IS NOT NULL THEN
FOR i IN array_lower(quote_array, 1) .. array_upper(quote_array, 1) LOOP
Expand Down Expand Up @@ -4578,4 +4590,4 @@ RESET ROLE;

SET ROLE pgstac_ingest;
SELECT update_partition_stats_q(partition) FROM partitions_view;
SELECT set_version('0.9.8');
SELECT set_version('unreleased');
12 changes: 12 additions & 0 deletions src/pgstac/sql/004_search.sql
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,18 @@ BEGIN
-- - -> !
processed_text := regexp_replace(processed_text, '^\s*\-([a-zA-Z0-9_]+)', '! \1', 'g'); -- -term at start
processed_text := regexp_replace(processed_text, '\s*\-([a-zA-Z0-9_]+)', ' & ! \1', 'g'); -- -term elsewhere

-- terms separated with spaces are assumed to represent an AND clause. loop through these
-- occurrences and replace them with &
LOOP
temp_text := regexp_replace(processed_text, '([a-zA-Z0-9_]+)\s+([a-zA-Z0-9_]+)(?!\s*[&|<>])', '\1 & \2', 'g');
IF temp_text = processed_text THEN
EXIT; -- No more replacements were made
END IF;
processed_text := temp_text;
END LOOP;


-- Replace placeholders back with quoted phrases if there were any
IF array_length(quote_array, 1) IS NOT NULL THEN
FOR i IN array_lower(quote_array, 1) .. array_upper(quote_array, 1) LOOP
Expand Down
2 changes: 1 addition & 1 deletion src/pgstac/sql/999_version.sql
Original file line number Diff line number Diff line change
@@ -1 +1 @@
SELECT set_version('0.9.8');
SELECT set_version('unreleased');
4 changes: 4 additions & 0 deletions src/pgstac/tests/basic/free_text.sql
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,7 @@ select collection_search('{"q": "\"bear or stranger\""}');
select collection_search('{"q": "office"}');

select collection_search('{"q": ["bear", "stranger"]}');

select collection_search('{"q": "large lizard"}');

select collection_search('{"q": "teenagers fight monsters"}');
7 changes: 7 additions & 0 deletions src/pgstac/tests/basic/free_text.sql.out
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,10 @@ select collection_search('{"q": "office"}');

select collection_search('{"q": ["bear", "stranger"]}');
{"links": [], "collections": [{"id": "testcollection_1", "type": "Collection", "title": "Stranger Things", "extent": {"spatial": [[-180, -90, 180, 90]], "temporal": [["2016-01-01T00:00:00+00:00", "2025-12-31T23:59:59+00:00"]]}, "keywords": null, "description": "Some teenagers drop out of school to fight scary monsters", "stac_extensions": []}, {"id": "testcollection_2", "type": "Collection", "title": "The Bear", "extent": {"spatial": [[-180, -90, 180, 90]], "temporal": [["2022-01-01T00:00:00+00:00", "2025-12-31T23:59:59+00:00"]]}, "keywords": ["restaurant", "funny", "sad", "great"], "description": "Another story about why you should not start a restaurant", "stac_extensions": []}], "numberMatched": 2, "numberReturned": 2}

select collection_search('{"q": "large lizard"}');
{"links": [], "collections": [{"id": "testcollection_3", "type": "Collection", "title": "Godzilla", "extent": {"spatial": [[-180, -90, 180, 90]], "temporal": [["1954-01-01T00:00:00+00:00", null]]}, "keywords": ["scary", "lizard", "monster"], "description": "A large lizard takes its revenge", "stac_extensions": []}], "numberMatched": 1, "numberReturned": 1}

select collection_search('{"q": "teenagers fight monsters"}');
{"links": [], "collections": [{"id": "testcollection_1", "type": "Collection", "title": "Stranger Things", "extent": {"spatial": [[-180, -90, 180, 90]], "temporal": [["2016-01-01T00:00:00+00:00", "2025-12-31T23:59:59+00:00"]]}, "keywords": null, "description": "Some teenagers drop out of school to fight scary monsters", "stac_extensions": []}], "numberMatched": 1, "numberReturned": 1}

2 changes: 1 addition & 1 deletion src/pypgstac/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "pypgstac"
version = "0.9.8"
version = "0.9.8-dev"
description = "Schema, functions and a python library for storing and accessing STAC collections and items in PostgreSQL"
readme = "README.md"
requires-python = ">=3.8"
Expand Down
2 changes: 1 addition & 1 deletion src/pypgstac/src/pypgstac/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Version."""

__version__ = "0.9.8"
__version__ = "0.9.8-dev"
Loading