Document

Document API #

Document API Reference #

Documents #

Below is the field description for the document.

FieldTypeDescription
sourceobjectThe source of the document.
categorystringPrimary category of the document, e.g., report.
subcategorystringSecondary category of the document, e.g., 2024.
categoriesarray[string]List of categories the document belongs to, e.g., ["business", "quarterly_reports"].
coverstring (URL)URL to the cover image of the document.
titlestringTitle of the document, e.g., Q3 Business Report.
summarystringA brief summary of the document content.
typestringType of the document, e.g., PDF.
langstringLanguage of the document, e.g., en.
contentstringThe main content or body of the document.
iconstring (URL)URL to the document’s icon.
thumbnailstring (URL)URL to the document’s thumbnail image.
tagsarray[string]Tags associated with the document, e.g., ["finance", "quarterly", "business", "report"].
urlstring (URL)URL link to the document, e.g., a Google Drive link.
sizeintegerSize of the document in bytes, e.g., 1048576 for 1 MB.
ownerobjectInformation about the document’s owner.
owner.avatarstring (URL)URL to the owner’s avatar image.
owner.usernamestringUsername of the owner, e.g., jdoe.
owner.useridstringUser ID of the owner, e.g., user123.
metadataobjectAdditional accessible metadata (e.g., file version, permissions).
payloadobjectAdditional store-only metadata (e.g., file binary data).
last_updated_byobjectInformation about the last user who updated the document.
last_updated_by.userobjectDetails about the user who last updated the document.
last_updated_by.user.avatarstring (URL)URL to the avatar of the last editor.
last_updated_by.user.usernamestringUsername of the last editor, e.g., editor123.
last_updated_by.user.useridstringUser ID of the last editor, e.g., editor123@example.com.
last_updated_by.timestampstring (datetime)Timestamp of the last update, e.g., 2024-11-01T15:30:00Z.

Index a Document #

//request
curl -H 'Content-Type: application/json' -XPOST http://localhost:9000/document/ -d '{
  "source": {
    "type":"connector",
    "name":"My Hugo Site",
    "id":"e806831dacc3",
  },
  "category": "report",
  "categories": ["business", "quarterly_reports"],
  "cover": "https://example.com/images/report_cover.jpg",
  "title": "Q3 Business Report",
  "summary": "An overview of the company financial performance for Q3.",
  "type": "PDF",
  "lang": "en",
  "content": "This quarters revenue increased by 15%, driven by strong sales in the APAC region...",
  "icon": "https://example.com/images/icon.png",
  "thumbnail": "https://example.com/images/report_thumbnail.jpg",
  "tags": ["finance", "quarterly", "business", "report"],
  "url": "https://drive.google.com/file/d/abc123/view",
  "size": 1048576,
  "owner": {
    "avatar": "https://example.com/images/user_avatar.jpg",
    "username": "jdoe",
    "userid": "user123"
  },
  "metadata": {
    "version": "1.2",
    "department": "Finance",
    "last_reviewed": "2024-10-20",
    "file_extension": "pdf",
    "icon_link": "https://example.com/images/file_icon.png",
    "has_thumbnail": true,
    "kind": "drive#file",
    "parents": ["folder123"],
    "properties": { "shared": "true" },
    "spaces": ["drive"],
    "starred": false,
    "driveId": "drive123",
    "thumbnail_link": "https://example.com/images/file_thumbnail.jpg",
    "video_media_metadata": { "durationMillis": "60000", "width": 1920, "height": 1080 },
    "image_media_metadata": { "width": 1024, "height": 768 }
  },
  "last_updated_by": {
    "user": {
      "avatar": "https://example.com/images/editor_avatar.jpg",
      "username": "editor123",
      "userid": "editor123@example.com"
    },
    "timestamp": "2024-11-01T15:30:00Z"
  }
}'

//response
{
  "_id": "cso9vr3q50k38nobvmcg",
  "result": "created"
}

Get a Document #

//request
curl   -XGET http://localhost:9000/document/cso9vr3q50k38nobvmcg

//response
{
  "_id": "cso9vr3q50k38nobvmcg",
  "_source": {
    "id": "cso9vr3q50k38nobvmcg",
    "created": "2024-11-10T19:58:36.009086+08:00",
    "updated": "2024-11-10T19:58:36.009092+08:00",
     "source": {
        "type":"connector",
        "name":"My Hugo Site",
        "id":"e806831dacc3",
      }
    ...OMITTED...
   ,
  "found": true
}

Update a Document #

//request
curl  -H 'Content-Type: application/json'   -XPUT http://localhost:9000/document/cso9vr3q50k38nobvmcg -d'{ "source": "google_drive", ...OMITTED... , "timestamp": "2024-11-01T15:30:00Z" } }'

//response
{
  "_id": "cso9vr3q50k38nobvmcg",
  "result": "updated"
}

Delete a Document #

//request
curl  -XDELETE http://localhost:9000/document/cso9vr3q50k38nobvmcg

//response
{
  "_id": "cso9vr3q50k38nobvmcg",
  "result": "deleted"
}
Edit Edit this page