Skip to content

Document

What is a document?

In Gainly, a document represents a fundamental data unit that contains information. Each document consists of:

  • Text: The primary text information, stored as free-form text.
    • Stored in title and content fields.
  • Metadata: Structured attributes that provide added context for the document.
    • Stored in fully-customizable arbitrary key-value pairs.

When you add a document to Gainly, our system analyzes and extracts the semantic meaning (the underlying context and relationships) from your document's text content. This extracted information is then stored in your dedicated semantic index.

When you use the Gainly API for operations like searching or classifying, you're working with this semantic index - allowing you to find and analyze documents based on their semantic meaning.

Practical examples

A document can be anything that you want to extract semantic meaning from. Usually a document is:

  • A record in your database, or an object in your app.

    Examples

    For example, in a video site each of these can be a document:

    • a Video (including comments)
    • a Channel
    • a Playlist
    • a Category
    • etc.

    For example, in a music app each of these can be a document:

    • a Song
    • an Artist
    • an Album
    • a Genre
    • etc.

    For example, in an ecommerce site each of these can be a document:

    • a Product (including reviews)
    • a Brand
    • a Category
    • an Order
    • etc.

    For example, in a CRM app each of these can be a document:

    • a Contact
    • a Company
    • an Email or Email thread
    • a Call note
    • etc.

    For example, in a store website each of these can be a document:

    • a Store Location
    • a Product (including reviews)
    • a Brand
    • a Category
    • etc.
  • A file in your app (PDF, Microsoft Word, HTML, Markdown, etc.)

How a document looks

Here's an example of a Gainly document for a song in a music app:

{
    "title": "Johnny B. Goode",
    "content": "Widely considered one of the most iconic songs in rock and roll, Johnny B. Goode is based on Chuck Berry’s life. It tells the tale of a boy with humble beginnings with a talent for guitar. Some details were changed: Berry was from St. Louis, not Louisiana, and he knew how to read and write very well. He graduated from beauty school with a degree in hairdressing and cosmetology. The song is well known for its catchy guitar riff.\n\nIn 1977, NASA sent a copy of this on the Voyager space probe as part of a package that was meant to represent the best in American culture. Someday, aliens could find it and discover Chuck Berry.\n\n[Verse 1]\nDeep down in Louisiana close to New Orleans\nWay back up in the woods among the evergreens\nThere stood a log cabin made of earth and wood\nWhere lived a country boy named Johnny B. Goode\nWho never ever learned to read or write so well\nBut he could play a guitar just like a ringin' a bell\n\n[Chorus]\nGo, go\nGo, Johnny, go, go\nGo, Johnny, go, go\nGo, Johnny, go, go\nGo, Johnny, go, go\nJohnny B. Goode\n\n[Verse 2]\nHe used to carry his guitar in a gunny sack\nGo sit beneath the tree by the railroad track\nOh, the engineers would see him sitting in the shade\nStrummin' with the rhythm that the drivers made\nPeople passing by, they would stop and say\n\"Oh, my, but that little country boy could play\"\n\n[Chorus]\nGo, go\nGo, Johnny, go, go\nGo, Johnny, go, go\nGo, Johnny, go, go\nGo, Johnny, go, go\nJohnny B. Goode\nSee upcoming rock shows\nGet tickets for your favorite artists\nYou might also like\nYou’re Losing Me (From The Vault)\nTaylor Swift\nGuilty as Sin?\nTaylor Swift\nMy Boy Only Breaks His Favorite Toys\nTaylor Swift\n[Guitar Solo]\n\n[Verse 3]\nHis mother told him, \"Someday you will be a man\nAnd you will be the leader of a big ol' band\nMany people coming from miles around\nTo hear you play your music when the sun go down\nMaybe someday your name will be in lights\nSayin' 'Johnny B. Goode Tonight'\"\n\n[Chorus]\nGo, go\nGo, Johnny, go\nGo, go, go, Johnny, go\nGo, go, go, Johnny, go\nGo, go, go, Johnny, go\nGo, Johnny B. Goode\n\nArtist: Chuck Berry\nGenre: Rock and roll\nLabel: Chess Records\nReleased: 1958.",
    "metadata": {
        "artist": "Chuck Berry",
        "label": "Chess Records",
        "released_on": "1958-03-31",
        "genre": "Rock and roll"
    }
}