|
3 | 3 | - **Title:** Free-Text Search |
4 | 4 | - **OpenAPI specification:** [openapi.yaml](openapi.yaml) |
5 | 5 | - **Conformance Classes:** |
6 | | - - <https://api.stacspec.org/v1.0.0-beta.2/item-search#free-text-search> |
| 6 | + - <https://api.stacspec.org/v1.0.0-rc.1/item-search#free-text> |
| 7 | + - <https://api.stacspec.org/v1.0.0-rc.1/item-search#advanced-free-text> |
| 8 | + - <https://api.stacspec.org/v1.0.0-rc.1/collection-search#free-text> |
| 9 | + - <https://api.stacspec.org/v1.0.0-rc.1/collection-search#advanced-free-text> |
| 10 | + - <https://api.stacspec.org/v1.0.0-rc.1/ogcapi-features#free-text> |
| 11 | + - <https://api.stacspec.org/v1.0.0-rc.1/ogcapi-features#advanced-free-text> |
7 | 12 | - **Scope:** STAC API - Core |
8 | 13 | - **[Extension Maturity Classification](https://github.com/radiantearth/stac-api-spec/tree/main/README.md#maturity-classification):** Proposal |
9 | | -- **Dependencies:** |
10 | | - - [STAC API - Core](https://github.com/radiantearth/stac-api-spec/tree/v1.0.0-rc.2/core) |
| 14 | +- **Dependencies:** (any of) |
| 15 | + - [STAC API - Collection Search](https://github.com/stac-api-extensions/collection-search) |
| 16 | + - [STAC API - Item Search](https://github.com/radiantearth/stac-api-spec/tree/v1.0.0/item-search) |
| 17 | + - [STAC API - Features](https://github.com/radiantearth/stac-api-spec/tree/v1.0.0/ogcapi-features) |
11 | 18 | - **Owner**: @agstephens |
12 | 19 |
|
13 | | -This defines a new parameter, `q` that allows the user to perform free-text queries against the item properties. |
| 20 | +This defines a new parameter, `q` that allows the user to perform free-text queries against STAC metadata. |
14 | 21 | The value of the parameter is a string and is passed to the underlying backend for free-text searches. |
15 | | -Queries can be executed either against all string property fields or against specific fields and can make use of `AND` and `OR` |
16 | | -operators. |
| 22 | +The specific set of text fields to which the parameter is applied is left to the discretion of the implementation, |
| 23 | +but a recommendation is to at least consider: |
| 24 | +- Collections: `title`, `description` and `keywords` |
| 25 | +- Catalog: `title`, `description` |
| 26 | +- Item: all relevant textual properties |
| 27 | +It is also allowed to query against all text fields. |
17 | 28 |
|
18 | 29 | This extension sits somewhere between the basic API and the [Filter Extension](https://github.com/radiantearth/stac-api-spec/tree/master/fragments/filter) providing |
19 | 30 | more powerful query features than the raw API but without the flexibility and increased operators of the filter plugin. This should mostly be used to provide |
20 | 31 | the ability to search for keywords across all properties with more complex queries and faceted search being provided by the filter extension. |
21 | 32 |
|
22 | | -## HTTP GET |
| 33 | +This extension defines two flavors of free text search. |
| 34 | +A simple one that is aligned with [OGC API - Records](https://docs.ogc.org/DRAFTS/20-004.html#_parameter_q) and |
| 35 | +a more advanced one. |
| 36 | +Both variants can be implemented against any of the search endpoints (Collection Search, Item Search, Features). |
23 | 37 |
|
24 | | -### Examples |
| 38 | +## Basic |
| 39 | + |
| 40 | +### HTTP GET / POST |
| 41 | + |
| 42 | +**Conformance Classes:** |
| 43 | + - Item Search (global): <https://api.stacspec.org/v1.0.0-rc.1/item-search#free-text> |
| 44 | + - Collection Search: <https://api.stacspec.org/v1.0.0-rc.1/collection-search#free-text> |
| 45 | + - Features (item search per collection): <https://api.stacspec.org/v1.0.0-rc.1/ogcapi-features#free-text> |
| 46 | + |
| 47 | +The basic free-text search adds a `q` query parameter to the request URI. |
| 48 | +See <https://docs.ogc.org/DRAFTS/20-004.html#_parameter_q> for details. |
| 49 | + |
| 50 | +The search works case-insensitive and spaces have no special meaning. |
| 51 | +Any of the search terms must be present in the set of text fields (OR operaror). |
| 52 | + |
| 53 | +- In HTTP `GET` requests, all search terms must be separated by a comma. For example, if you want to search for "Earth Observation" or "EO", your query parameter should be as follows: `q=EO,Earth Observation`. |
| 54 | +- In HTTP `POST` requests, an array of search terms must be provided, for example: `{"q": ["EO", "Earth Observation"]}`. |
| 55 | + |
| 56 | +## Advanced |
| 57 | + |
| 58 | +**Conformance Classes:** |
| 59 | + - Item Search (global): <https://api.stacspec.org/v1.0.0-rc.1/item-search#advanced-free-text> |
| 60 | + - Collection Search: <https://api.stacspec.org/v1.0.0-rc.1/collection-search#advanced-free-text> |
| 61 | + - Features (item search per collection): <https://api.stacspec.org/v1.0.0-rc.1/ogcapi-features#advanced-free-text> |
| 62 | + |
| 63 | +**OpenAPI document:** [openapi.yaml](openapi.yaml) |
| 64 | + |
| 65 | +### HTTP GET |
| 66 | + |
| 67 | +**Examples:** |
25 | 68 |
|
26 | 69 | | URL Example | Summary | Detail | |
27 | 70 | | ----------- | ------- | ------ | |
28 | | -| `/search?q=sentinel` | Free-text query against all properties | This will search for any matching items where `properties.*` CONTAINS `"sentinel"` | |
29 | | -| `/search?q="climate model"` | Free-text search using exact | This will search for any matching items where `properties.*` CONTAINS the exact phrase `"climate model"` | |
30 | | -|`/search?q=climate model`| Using `OR` term match (**Default**) | This will search for any matching items where `properties.*` CONTAINS `"climate"` OR `"model"`| |
31 | | -|`/search?q=climate OR model`| Using `OR` term match (**Default**) | This will search for any matching items where `properties.*` CONTAINS `"climate"` OR `"model"`| |
32 | | -|`/search?q=climate AND model`| Using `AND` term match | This will search for any matching items where `properties.*` CONTAINS `"climate"` AND `"model"`| |
33 | | -| `/search?q=(quick OR brown) AND fox` | Parentheses can be used to group terms | This will search for matching items where `properties.*` CONTAINS `"quick"` OR `"brown"` AND `"fox"` | |
34 | | -| `/search?q=quick +brown -fox` | Indicate included and excluded terms using `+`/`-` | This will search for items where `properties.*` INCLUDES `"brown"` EXCLUDES `"fox"` OR CONTAINS `"quick"` | |
| 71 | +| `/search?q=sentinel` | Free-text query against all properties | This will search for any matching items that CONTAIN `"sentinel"` | |
| 72 | +| `/search?q="climate model"` | Free-text search using exact | This will search for any matching items that CONTAIN the exact phrase `"climate model"` | |
| 73 | +|`/search?q=climate model`| Using `OR` term match (**Default**) | This will search for any matching items that CONTAIN `"climate"` OR `"model"`| |
| 74 | +|`/search?q=climate OR model`| Using `OR` term match (**Default**) | This will search for any matching items that CONTAIN `"climate"` OR `"model"`| |
| 75 | +|`/search?q=climate AND model`| Using `AND` term match | This will search for any matching items that CONTAIN `"climate"` AND `"model"`| |
| 76 | +| `/search?q=(quick OR brown) AND fox` | Parentheses can be used to group terms | This will search for matching items that CONTAIN `"quick"` OR `"brown"` AND `"fox"` | |
| 77 | +| `/search?q=quick +brown -fox` | Indicate included and excluded terms using `+`/`-` | This will search for items that INCLUDES `"brown"` EXCLUDES `"fox"` OR CONTAIN `"quick"` | |
35 | 78 |
|
36 | | -## HTTP POST |
| 79 | +### HTTP POST |
37 | 80 |
|
38 | | -When calling the relevant endpoint using POST withContent-Type: application/json, this adds an attribute q with an object value to the core JSON search request body. |
| 81 | +When calling the relevant endpoint using `POST` with `Content-Type: application/json`, this adds an attribute `q` with an object value to the core JSON search request body. |
39 | 82 |
|
40 | 83 | The syntax for the q attribute is: |
41 | 84 |
|
|
0 commit comments