Autocomplete API

CMR-6157 - Getting issue details... STATUS

The CMR autocomplete API will provide autocomplete suggestions via a RESTful call to an AWS Lambda.

A secondary implementation will use WebSockets. The WebSocket implementation is a stretch goal.
If the WebSocket implementation is completed, the data format for the responses will share the same response schema as the RESTful implementation.


OpenAPI 3.0

openapi.yaml

View with https://editor.swagger.io/ or using Docker with

docker container run --rm -p 80:8080 swaggerapi/swagger-editor



/search/autocomplete

Query with a term

Fetch autocomplete suggestions from all available facets

curl -XGET https://.../autocomplete?q=ex

Example Response

HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
CMR-Hits: 4
CMR-Took: 382

{
  "feed": {
    "entry": [
      {
        "type": "platform",
        "value": "EXOS-A",
        "score": 3.17234
      },
      {
        "type": "instrument",
        "value": "EXRAD",
        "score": 2.36234
      },
      {
        "type": "platform",
        "value": "EXPLORER-9",
        "score": 0.15234
      },
      {
        "type": "provider",
        "value": "PURDUE/EXTENSION",
        "score": 0.12323
      }
    ]
  }
}

Query with type filter

Only return suggestions from the supplied type

curl -XGET https://.../autocomplete?q=ice&type[]=instrument
Example Response


HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
CMR-Hits: 1
CMR-Took: 440

{
  "feed": {
    "entry": [
      {
        "type": "instrument",
        "value": "ICE AUGER",
        "score": 0.281
      }
    ]
  }
}

Query with multiple types

Multiple types may be specified. The order of types provided may not reflect order returned in results array. Only valid facets will be used, unrecognized terms will not be included in results.

curl -XGET https://.../autocomplete?q=sol&type[]=platform&type[]=instrument
Example Response


HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
CMR-Hits: 3
CMR-Took: 166

{
  "feed": {
    "entry": [
      {
        "type": "platform",
        "value": "SOLAR-A",
        "score": 0.28234
      },
      {
        "type": "platform",
        "value": "SOLSAT",
        "score": 0.281
      },
      {
        "type": "instrument",
        "value": "SOLARIZER",
        "score": 0.263
      }
    ]
  }
}

Query with no results

curl -XGET https://.../autocomplete?q=foo
Example Response


HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
CMR-Hits: 0
CMR-Took: 122

{
  "feed": {
    "entry": []
  }
}
  • No labels

3 Comments

  1. This could use example curls and responses.

    1. user-b39c6

      I added a few examples for different permutations of queries and results.

  2. user-b39c6

    Since this version is rather specific to collections search, I'll probably add it to the `/search/collections/autocomplete` endpoint. That way if it can be added to other more specific searches like /search/granules etc...