|
| 1 | +SET pgstac.context TO 'on'; |
| 2 | +SET |
| 3 | +SET pgstac."default_filter_lang" TO 'cql2-json'; |
| 4 | +SET |
| 5 | +CREATE TEMP TABLE temp_collections ( |
| 6 | + id SERIAL PRIMARY KEY, |
| 7 | + title TEXT, |
| 8 | + description TEXT, |
| 9 | + keywords TEXT, |
| 10 | + minx NUMERIC, |
| 11 | + miny NUMERIC, |
| 12 | + maxx NUMERIC, |
| 13 | + maxy NUMERIC, |
| 14 | + sdt TIMESTAMPTZ, |
| 15 | + edt TIMESTAMPTZ |
| 16 | +); |
| 17 | +CREATE TABLE |
| 18 | +INSERT INTO temp_collections ( |
| 19 | + title, description, keywords, minx, miny, maxx, maxy, sdt, edt |
| 20 | +) VALUES |
| 21 | + ( |
| 22 | + 'Stranger Things', |
| 23 | + 'Some teenagers drop out of school to fight monsters', |
| 24 | + 'monster, scary, dark, 80s', |
| 25 | + -180, -90, 180, 90, |
| 26 | + '2016-01-01T00:00:00Z', |
| 27 | + '2025-12-31T23:59:59Z' |
| 28 | + ), |
| 29 | + ( |
| 30 | + 'The Bear', |
| 31 | + 'Another story about why you should not start a restaurant', |
| 32 | + 'restaurant, funny, sad, great', |
| 33 | + -180, -90, 180, 90, |
| 34 | + '2022-01-01T00:00:00Z', |
| 35 | + '2025-12-31T23:59:59Z' |
| 36 | + ), |
| 37 | + ( |
| 38 | + 'Godzilla', |
| 39 | + 'A large lizard takes its revenge', |
| 40 | + 'scary, lizard, monster', |
| 41 | + -180, -90, 180, 90, |
| 42 | + '1954-01-01T00:00:00Z', |
| 43 | + null |
| 44 | + ), |
| 45 | + ( |
| 46 | + 'Chefs Table', |
| 47 | + 'Another great story that make you wonder if you should go to a restaurant', |
| 48 | + 'restaurant, food, michelin', |
| 49 | + -180, -90, 180, 90, |
| 50 | + '2019-01-01T00:00:00Z', |
| 51 | + '2025-12-31T23:59:59Z' |
| 52 | + ); |
| 53 | +INSERT 0 4 |
| 54 | +SELECT |
| 55 | + create_collection(jsonb_build_object( |
| 56 | + 'id', format('testcollection_%s', id), |
| 57 | + 'type', 'Collection', |
| 58 | + 'title', title, |
| 59 | + 'description', description, |
| 60 | + 'extent', jsonb_build_object( |
| 61 | + 'spatial', jsonb_build_array(jsonb_build_array(minx, miny, maxx, maxy)), |
| 62 | + 'temporal', jsonb_build_array(jsonb_build_array(sdt, edt)) |
| 63 | + ), |
| 64 | + 'stac_extensions', jsonb_build_array(), |
| 65 | + 'keywords', string_to_array(keywords, ', ') |
| 66 | + )) |
| 67 | +FROM temp_collections; |
| 68 | + |
| 69 | + |
| 70 | + |
| 71 | + |
| 72 | +select collection_search('{"q": "monsters"}'); |
| 73 | + {"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} |
| 74 | + |
| 75 | + |
| 76 | +select collection_search('{"q": "lizard"}'); |
| 77 | + {"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} |
| 78 | + |
| 79 | + |
| 80 | +select collection_search('{"q": "scary OR funny"}'); |
| 81 | + {"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} |
| 82 | + |
| 83 | +select collection_search('{"q": "(scary AND revenge) OR (funny AND sad)"}'); |
| 84 | + {"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} |
| 85 | + |
| 86 | +select collection_search('{"q": "\"great story\""}'); |
| 87 | + {"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} |
| 88 | + |
| 89 | +select collection_search('{"q": "monster -school"}'); |
| 90 | + {"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} |
| 91 | + |
| 92 | +select collection_search('{"q": "bear or stranger"}'); |
| 93 | + {"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} |
| 94 | + |
| 95 | +select collection_search('{"q": "bear OR stranger"}'); |
| 96 | + {"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} |
| 97 | + |
| 98 | +select collection_search('{"q": "bear, stranger"}'); |
| 99 | + {"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} |
| 100 | + |
| 101 | +select collection_search('{"q": "bear AND stranger"}'); |
| 102 | + {"links": [], "collections": [], "numberMatched": 0, "numberReturned": 0} |
| 103 | + |
| 104 | +select collection_search('{"q": "bear and stranger"}'); |
| 105 | + {"links": [], "collections": [], "numberMatched": 0, "numberReturned": 0} |
| 106 | + |
| 107 | +select collection_search('{"q": "\"bear or stranger\""}'); |
| 108 | + {"links": [], "collections": [], "numberMatched": 0, "numberReturned": 0} |
| 109 | + |
0 commit comments