Skip to content

Pushing JSON Files with the Coveo CLI

jpmarceau edited this page Jul 21, 2021 · 2 revisions

The Coveo CLI exposes various commands that allow you to push correctly formatted JSON documents to the Coveo Cloud Push API.

Minimal Document Content

For a document to be considered valid by the Coveo Cloud Push API, it needs to minimally contain a title and a URI:

{
   "title": "Batman",
   "documentId": "https://themoviedb.org/movie/268"
}

Where:

  • title is a non empty string.
  • documentId is a non empty valid URI.

Secured Content

You can push secured content in the following format:

{
  "documentId": "https://themoviedb.org/movie/268",
  "title": "Batman",
  "permissions": {
    "allowAnonymous": false,
    "allowedPermissions": [
      {
        "identity": "bob@anonymous.com",
        "identityType": "USER",
        "securityProvider": "Email Security Provider"
      }
    ],
    "deniedPermissions": [
      {
        "identity": "MarketingTeam",
        "identityType": "GROUP",
        "securityProvider": "My Security Provider"
      }
    ]
  }
}

Where the parameter structure is as follows:

  • permissions is an object.
    • allowAnonymous is a boolean.
    • allowedPermissions and deniedPermissions are arrays.
      • identity is a non empty string.
      • identityType is one of the following strings: 'UNKNOWN' or 'USER' or 'GROUP' or 'VIRTUAL_GROUP'.
      • securityProvider is a non empty string.

Additional Important Content

Some attributes are not mandatory, but recommended:

{
   "documentId": "https://themoviedb.org/movie/268",
   "title": "Batman",
   "data": "Batman (1989) \n Based on the Character created by Bob Kane. \n EXT. CITYSCAPE - NIGHT \n Gotham City.  The City of Tomorrow:  stark angles, creeping shadows, dense, crowded, as if hell had erupted through the sidewalks.  A dangling fat moon shines overhead. \n At the opposite corner of the roof, some fifteen yards away... at the end of a line, a STRANGE BLACK SILHOUETTE is dropping slowly, implacably, into frame...",
   "clickableUri": "https://themoviedb.org/movie/268",
   "date": "1989-06-13T12:00:00.000Z"
}
  • data is a string containing the searchable text for this document (see Pushing Item Data).
  • clickableUri is a string that can be used to set a URL that end users can use to reach the document. Can be omitted if the documentId already contains a valid clickable URL.
  • date is a string that can be used to set the date of the document. If omitted, the Push API uses the current date (see Automatically Included Standard Metadata).

Metadata

Any other metadata that you would like to push can be set as key-value pairs in the JSON document:

{
   "documentId": "https://themoviedb.org/movie/268",
   "title": "Batman",
   "poster": "https://www.themoviedb.org/t/p/w1280/tDexQyu6FWltcd0VhEDK7uib42f.jpg",
   "tagline": "Have you ever danced with the devil in the pale moonlight?",
   "summary": "The Dark Knight of Gotham City begins his war on crime with his first major enemy being the clownishly homicidal Joker, who has seized control of Gotham's underworld.",
   "actors": ["Jack Nicholson", "Michael Keaton", "Kim Basinger"]
}

Multiple Documents in the Same File

A file can contain either one or multiple documents.

Single Document

{
   "documentId": "https://themoviedb.org/movie/268",
   "title": "Batman"
}

Multiple Documents

[
  {
    "documentId": "https://www.themoviedb.org/movie/268",
    "title": "Batman",
  },
  {
    "documentId": "https://www.themoviedb.org/movie/550",
    "title": "Fight Club",
  }
]