Skip to content

Commit d035722

Browse files
authored
Merge pull request #7 from m-mohr/master
Rewrite Free-Text Search extension (fixes #3, #5, #6)
2 parents 21831ba + a525532 commit d035722

File tree

3 files changed

+60
-41
lines changed

3 files changed

+60
-41
lines changed

.swagger-codegen-ignore

Lines changed: 0 additions & 23 deletions
This file was deleted.

.swagger-codegen/VERSION

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 60 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,82 @@
33
- **Title:** Free-Text Search
44
- **OpenAPI specification:** [openapi.yaml](openapi.yaml)
55
- **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>
712
- **Scope:** STAC API - Core
813
- **[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)
1118
- **Owner**: @agstephens
1219

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.
1421
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.
1728

1829
This extension sits somewhere between the basic API and the [Filter Extension](https://github.com/radiantearth/stac-api-spec/tree/master/fragments/filter) providing
1930
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
2031
the ability to search for keywords across all properties with more complex queries and faceted search being provided by the filter extension.
2132

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).
2337

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:**
2568

2669
| URL Example | Summary | Detail |
2770
| ----------- | ------- | ------ |
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"` |
3578

36-
## HTTP POST
79+
### HTTP POST
3780

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.
3982

4083
The syntax for the q attribute is:
4184

0 commit comments

Comments
 (0)