|
| 1 | +| | | |
| 2 | +|---|---| |
| 3 | +| **OpenAPI Specification** | [openapi.yaml](openapi.yaml) | |
| 4 | +| **Conformance Class** | https://api.stacspec.org/v1.0.0-beta.2/item-search#free-text-search | |
| 5 | +| **[Maturity Classification](https://github.com/radiantearth/stac-api-spec/blob/master/extensions.md#extension-maturity)** | Pilot | |
| 6 | +| **Dependents** | - Item Search | |
| 7 | + |
| 8 | +This defines a new parameter, `q` that allows the user to perform free-text queries against the item properties. |
| 9 | +The value of the parameter is a string and is passed to the underlying backend for free-text searches. |
| 10 | +Queries can be executed either against all string property fields or against specific fields and can make use of `AND` and `OR` |
| 11 | +operators. |
| 12 | + |
| 13 | +This extension sits somewhere between the basic API and the [Filter Extension](https://github.com/radiantearth/stac-api-spec/tree/master/fragments/filter) providing |
| 14 | +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 |
| 15 | +the ability to search for keywords across all properties with more complex queries and faceted search being provided by the filter extension. |
| 16 | + |
| 17 | +## HTTP GET |
| 18 | + |
| 19 | +### Examples |
| 20 | + |
| 21 | +#### Free-text query against all properties |
| 22 | + |
| 23 | +`/search?q=sentinel` |
| 24 | + |
| 25 | +This will search for any matching items where `properties.*` CONTAINS `sentinel` |
| 26 | + |
| 27 | +#### Free-text query against specific property |
| 28 | + |
| 29 | +`/search?q=sat:orbit_state:ascending` |
| 30 | + |
| 31 | +This will search for any matching items where `properties.sat:obit_state` CONTAINS `ascending` |
| 32 | + |
| 33 | +#### Free-text search using exact |
| 34 | + |
| 35 | +`/search?q=climate model` |
| 36 | + |
| 37 | +This will search for any matching items where `properties.*` CONTAINS the exact phrase `"climate model"` |
| 38 | + |
| 39 | +#### Free-text search using operators |
| 40 | + |
| 41 | +By default, query strings which are made of multiple strings are searched using and `OR` relationship |
| 42 | + |
| 43 | +`/search?q=climate model` |
| 44 | + |
| 45 | +This will search for any matching items where `properties.*` CONTAINS `climate` OR `model` |
| 46 | + |
| 47 | +`/search?q=climate & model` |
| 48 | + |
| 49 | +This will search for any matching items where `properties.*` CONTAINS `climate` AND `model` |
| 50 | + |
| 51 | +## HTTP POST |
| 52 | + |
| 53 | +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. |
| 54 | + |
| 55 | +The syntax for the q attribute is: |
| 56 | + |
| 57 | +```json |
| 58 | +{ |
| 59 | + "q": "your query string" |
| 60 | +} |
| 61 | +``` |
| 62 | + |
| 63 | +See [examples](#examples) section for more complex queries |
0 commit comments