Skip to content

This defines a new parameter, q that allows the user to perform free-text queries against the item properties.

Notifications You must be signed in to change notification settings

stac-api-extensions/freetext-search

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 

Repository files navigation

STAC API - Free-Text Search

This defines a new parameter, q that allows the user to perform free-text queries against STAC metadata. The value of the parameter is a string and is passed to the underlying backend for free-text searches. The specific set of text fields to which the parameter is applied is left to the discretion of the implementation, but a recommendation is to at least consider:

  • Collections: title, description and keywords
  • Catalog: title, description
  • Item: all relevant textual properties It is also allowed to query against all text fields.

This extension sits somewhere between the basic API and the Filter Extension providing 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 the ability to search for keywords across all properties with more complex queries and faceted search being provided by the filter extension.

This extension defines two flavors of free text search. A simple one that is aligned with OGC API - Records and a more advanced one. Both variants can be implemented against any of the search endpoints (Collection Search, Item Search, Features).

Basic

HTTP GET / POST

Conformance Classes:

The basic free-text search adds a q query parameter to the request URI. See https://docs.ogc.org/DRAFTS/20-004.html#_parameter_q for details.

The search works case-insensitive and spaces have no special meaning. Any of the search terms must be present in the set of text fields (OR operaror).

  • 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.
  • In HTTP POST requests, an array of search terms must be provided, for example: {"q": ["EO", "Earth Observation"]}.

Advanced

Conformance Classes:

OpenAPI document: openapi.yaml

HTTP GET

Examples:

URL Example Summary Detail
/search?q=sentinel Free-text query against all properties This will search for any matching items that CONTAIN "sentinel"
/search?q="climate model" Free-text search using exact This will search for any matching items that CONTAIN the exact phrase "climate model"
/search?q=climate model Using OR term match (Default) This will search for any matching items that CONTAIN "climate" OR "model"
/search?q=climate OR model Using OR term match (Default) This will search for any matching items that CONTAIN "climate" OR "model"
/search?q=climate AND model Using AND term match This will search for any matching items that CONTAIN "climate" AND "model"
/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"
/search?q=quick +brown -fox Indicate included and excluded terms using +/- This will search for items that INCLUDES "brown" EXCLUDES "fox" OR CONTAIN "quick"

HTTP POST

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.

The syntax for the q attribute is:

{
  "q": "your query string"
}

See examples section for more complex queries

About

This defines a new parameter, q that allows the user to perform free-text queries against the item properties.

Resources

Stars

Watchers

Forks

Packages

No packages published