You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 42 Next »

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/collections/autocomplete

Query with a term

Fetch autocomplete suggestions from all available facets

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

Example Response

{
  "query": {
    "query": "ex",
    "types": []
  },
  "results": {
    "hits": 4,
    "items": [
      {
        "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


{
  "query": {
    "query": "ic",
    "types": [
      "instrument"
    ]
  },
  "results": {
    "hits": 1,
    "items": [
      {
        "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,instrument
Example Response


{
  "query": {
    "query": "sol",
    "types": [
      "platform",
      "instrument"
    ]
  },
  "results": {
    "hits": 3,
    "items": [
      {
        "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


{
  "query": {
    "query": "foo",
    "types": []
  },
  "results": {
    "hits": 0,
    "items": []
  }
}
 


Architecture

AWS Lambda provides the logic for hosting and interacting with Redis and returning responses.

A Redis cache will keep the entries available for rapid search and retrieval.

  • No labels