-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add q parameter for free-text search (#295)
* add q parameter for free-text search * handle quoted statements, add more tests
- Loading branch information
Showing
10 changed files
with
5,406 additions
and
46 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
migrations/pgstac.0.9.1.sql | ||
migrations/pgstac.unreleased.sql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
SELECT set_version('0.9.1'); | ||
SELECT set_version('unreleased'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
|
||
SET pgstac.context TO 'on'; | ||
SET pgstac."default_filter_lang" TO 'cql2-json'; | ||
|
||
CREATE TEMP TABLE temp_collections ( | ||
id SERIAL PRIMARY KEY, | ||
title TEXT, | ||
description TEXT, | ||
keywords TEXT, | ||
minx NUMERIC, | ||
miny NUMERIC, | ||
maxx NUMERIC, | ||
maxy NUMERIC, | ||
sdt TIMESTAMPTZ, | ||
edt TIMESTAMPTZ | ||
); | ||
|
||
INSERT INTO temp_collections ( | ||
title, description, keywords, minx, miny, maxx, maxy, sdt, edt | ||
) VALUES | ||
( | ||
'Stranger Things', | ||
'Some teenagers drop out of school to fight monsters', | ||
'monster, scary, dark, 80s', | ||
-180, -90, 180, 90, | ||
'2016-01-01T00:00:00Z', | ||
'2025-12-31T23:59:59Z' | ||
), | ||
( | ||
'The Bear', | ||
'Another story about why you should not start a restaurant', | ||
'restaurant, funny, sad, great', | ||
-180, -90, 180, 90, | ||
'2022-01-01T00:00:00Z', | ||
'2025-12-31T23:59:59Z' | ||
), | ||
( | ||
'Godzilla', | ||
'A large lizard takes its revenge', | ||
'scary, lizard, monster', | ||
-180, -90, 180, 90, | ||
'1954-01-01T00:00:00Z', | ||
null | ||
), | ||
( | ||
'Chefs Table', | ||
'Another great story that make you wonder if you should go to a restaurant', | ||
'restaurant, food, michelin', | ||
-180, -90, 180, 90, | ||
'2019-01-01T00:00:00Z', | ||
'2025-12-31T23:59:59Z' | ||
); | ||
|
||
SELECT | ||
create_collection(jsonb_build_object( | ||
'id', format('testcollection_%s', id), | ||
'type', 'Collection', | ||
'title', title, | ||
'description', description, | ||
'extent', jsonb_build_object( | ||
'spatial', jsonb_build_array(jsonb_build_array(minx, miny, maxx, maxy)), | ||
'temporal', jsonb_build_array(jsonb_build_array(sdt, edt)) | ||
), | ||
'stac_extensions', jsonb_build_array(), | ||
'keywords', string_to_array(keywords, ', ') | ||
)) | ||
FROM temp_collections; | ||
|
||
select collection_search('{"q": "monsters"}'); | ||
|
||
select collection_search('{"q": "lizard"}'); | ||
|
||
select collection_search('{"q": "scary OR funny"}'); | ||
|
||
select collection_search('{"q": "(scary AND revenge) OR (funny AND sad)"}'); | ||
|
||
select collection_search('{"q": "\"great story\""}'); | ||
|
||
select collection_search('{"q": "monster -school"}'); | ||
|
||
select collection_search('{"q": "bear or stranger"}'); | ||
|
||
select collection_search('{"q": "bear OR stranger"}'); | ||
|
||
select collection_search('{"q": "bear, stranger"}'); | ||
|
||
select collection_search('{"q": "bear AND stranger"}'); | ||
|
||
select collection_search('{"q": "bear and stranger"}'); | ||
|
||
select collection_search('{"q": "\"bear or stranger\""}'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
SET pgstac.context TO 'on'; | ||
SET | ||
SET pgstac."default_filter_lang" TO 'cql2-json'; | ||
SET | ||
CREATE TEMP TABLE temp_collections ( | ||
id SERIAL PRIMARY KEY, | ||
title TEXT, | ||
description TEXT, | ||
keywords TEXT, | ||
minx NUMERIC, | ||
miny NUMERIC, | ||
maxx NUMERIC, | ||
maxy NUMERIC, | ||
sdt TIMESTAMPTZ, | ||
edt TIMESTAMPTZ | ||
); | ||
CREATE TABLE | ||
INSERT INTO temp_collections ( | ||
title, description, keywords, minx, miny, maxx, maxy, sdt, edt | ||
) VALUES | ||
( | ||
'Stranger Things', | ||
'Some teenagers drop out of school to fight monsters', | ||
'monster, scary, dark, 80s', | ||
-180, -90, 180, 90, | ||
'2016-01-01T00:00:00Z', | ||
'2025-12-31T23:59:59Z' | ||
), | ||
( | ||
'The Bear', | ||
'Another story about why you should not start a restaurant', | ||
'restaurant, funny, sad, great', | ||
-180, -90, 180, 90, | ||
'2022-01-01T00:00:00Z', | ||
'2025-12-31T23:59:59Z' | ||
), | ||
( | ||
'Godzilla', | ||
'A large lizard takes its revenge', | ||
'scary, lizard, monster', | ||
-180, -90, 180, 90, | ||
'1954-01-01T00:00:00Z', | ||
null | ||
), | ||
( | ||
'Chefs Table', | ||
'Another great story that make you wonder if you should go to a restaurant', | ||
'restaurant, food, michelin', | ||
-180, -90, 180, 90, | ||
'2019-01-01T00:00:00Z', | ||
'2025-12-31T23:59:59Z' | ||
); | ||
INSERT 0 4 | ||
SELECT | ||
create_collection(jsonb_build_object( | ||
'id', format('testcollection_%s', id), | ||
'type', 'Collection', | ||
'title', title, | ||
'description', description, | ||
'extent', jsonb_build_object( | ||
'spatial', jsonb_build_array(jsonb_build_array(minx, miny, maxx, maxy)), | ||
'temporal', jsonb_build_array(jsonb_build_array(sdt, edt)) | ||
), | ||
'stac_extensions', jsonb_build_array(), | ||
'keywords', string_to_array(keywords, ', ') | ||
)) | ||
FROM temp_collections; | ||
|
||
|
||
|
||
|
||
select collection_search('{"q": "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": ["monster", "scary", "dark", "80s"], "description": "Some teenagers drop out of school to fight monsters", "stac_extensions": []}, {"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": 2, "numberReturned": 2} | ||
|
||
|
||
select collection_search('{"q": "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": "scary OR funny"}'); | ||
{"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": ["monster", "scary", "dark", "80s"], "description": "Some teenagers drop out of school to fight 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": []}, {"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": 3, "numberReturned": 3} | ||
|
||
select collection_search('{"q": "(scary AND revenge) OR (funny AND sad)"}'); | ||
{"links": [], "collections": [{"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": []}, {"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": 2, "numberReturned": 2} | ||
|
||
select collection_search('{"q": "\"great story\""}'); | ||
{"links": [], "collections": [{"id": "testcollection_4", "type": "Collection", "title": "Chefs Table", "extent": {"spatial": [[-180, -90, 180, 90]], "temporal": [["2019-01-01T00:00:00+00:00", "2025-12-31T23:59:59+00:00"]]}, "keywords": ["restaurant", "food", "michelin"], "description": "Another great story that make you wonder if you should go to a restaurant", "stac_extensions": []}], "numberMatched": 1, "numberReturned": 1} | ||
|
||
select collection_search('{"q": "monster -school"}'); | ||
{"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": "bear or 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": ["monster", "scary", "dark", "80s"], "description": "Some teenagers drop out of school to fight 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": "bear OR 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": ["monster", "scary", "dark", "80s"], "description": "Some teenagers drop out of school to fight 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": "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": ["monster", "scary", "dark", "80s"], "description": "Some teenagers drop out of school to fight 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": "bear AND stranger"}'); | ||
{"links": [], "collections": [], "numberMatched": 0, "numberReturned": 0} | ||
|
||
select collection_search('{"q": "bear and stranger"}'); | ||
{"links": [], "collections": [], "numberMatched": 0, "numberReturned": 0} | ||
|
||
select collection_search('{"q": "\"bear or stranger\""}'); | ||
{"links": [], "collections": [], "numberMatched": 0, "numberReturned": 0} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
"""Version.""" | ||
__version__ = "0.9.1" | ||
__version__ = "0.9.1-dev" |