-
Notifications
You must be signed in to change notification settings - Fork 48
add q parameter for free-text search #295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.