Query Facets

Query with faceted results.

Query With Facets

In addition to returning content results from a query, you can get faceted results from a wide variety of content properties.

For the full list of content facet types, look here in the GraphQL schema.

As part of the contents query, add a list of facet objects, where the facet property is the field you wish to count, within your content results.

Note, the facets are counted after the filter has been applied.

When using a date facet, you can assign the timeInterval to be grouped on, and an optional timeOffset to adjust for the timezone. If not specified, the grouping will be done based on UTC time.

Currently, faceted results are not supported with vector search. If using VECTOR or HYBRID search type, no faceted results will be returned.

Query:

query QueryContents($filter: ContentFilter!, $facets: [ContentFacetInput]) {
  contents(filter: $filter, facets: $facets) {
    results {
      id
      name
      creationDate
      owner {
        id
      }
      state
      originalDate
      finishedDate
      workflowDuration
      uri
      text
      type
      fileType
      mimeType
      fileName
      fileSize
      masterUri
      mezzanineUri
      transcriptUri
      links {
        uri
        linkType
      }
      document {
        title
        subject
        summary
        author
        publisher
        description
        keywords
        pageCount
      }
    }
    facets {
      facet
      count
      type
      value
      range {
        from
        to
      }
      observable {
        type
        observable {
          id
          name
        }
      }
    }
  }
}

Variables:

{
  "filter": {
    "types": [
      "FILE"
    ],
    "fileTypes": [
      "DOCUMENT"
    ],
    "offset": 0,
    "limit": 100
  },
  "facets": [
    {
      "facet": "ORIGINAL_DATE",
      "timeInterval": "MONTH",
      "timeOffset": -7
    },
    {
      "facet": "CONTENT_TYPE"
    },
    {
      "facet": "FILE_TYPE"
    }
  ]
}

Response:

{
  "results": [
    {
      "type": "FILE",
      "originalDate": "2023-10-18T19:28:45Z",
      "mimeType": "application/vnd.ms-excel",
      "fileType": "DOCUMENT",
      "fileName": "file.csv",
      "fileSize": 1992119,
      "masterUri": "redacted",
      "collections": [],
      "uri": "https://graphlitplatform.blob.core.windows.net/one-of-each/file.csv",
      "id": "7802bf1d-8e0c-4165-84ce-318cf59f5550",
      "name": "file",
      "state": "FINISHED",
      "creationDate": "2023-10-18T19:31:45Z",
      "finishedDate": "2023-10-18T19:31:54Z",
      "workflowDuration": "PT6.9426535S",
      "owner": {
        "id": "e409b47b-3ee9-48e9-a766-b3c30247e402"
      }
    },
    {
      "type": "FILE",
      "originalDate": "2023-10-18T19:28:44Z",
      "links": [
        {
          "uri": "https://deckard.rendered.ai/register/",
          "linkType": "WEB"
        },
        {
          "uri": "https://support.rendered.ai/rd/Quick-Start-Guide.1577779251.html",
          "linkType": "FILE"
        },
        {
          "uri": "https://www.youtube.com/watch?v=KGbMa6s1hrY&t=1s",
          "linkType": "YOU_TUBE"
        },
        {
          "uri": "https://support.rendered.ai/gc/index.html",
          "linkType": "FILE"
        },
        {
          "uri": "https://github.com/Rendered-ai/ana",
          "linkType": "GIT_HUB"
        }
      ],
      "mimeType": "text/html",
      "fileType": "DOCUMENT",
      "fileName": "file.html",
      "fileSize": 4809,
      "masterUri": "redacted",
      "mezzanineUri": "redacted",
      "document": {},
      "collections": [],
      "uri": "https://graphlitplatform.blob.core.windows.net/one-of-each/file.html",
      "id": "0f6979cf-d02a-4c52-91ea-a1418d38b0c4",
      "name": "file",
      "state": "FINISHED",
      "creationDate": "2023-10-18T19:31:45Z",
      "finishedDate": "2023-10-18T19:32:09Z",
      "workflowDuration": "PT22.0125484S",
      "owner": {
        "id": "e409b47b-3ee9-48e9-a766-b3c30247e402"
      }
    },
    {
      "type": "FILE",
      "originalDate": "2023-10-18T19:28:44Z",
      "mimeType": "application/msword",
      "fileType": "DOCUMENT",
      "fileName": "file.rtf",
      "fileSize": 295392,
      "masterUri": "redacted",
      "mezzanineUri": "redacted",
      "collections": [],
      "uri": "https://graphlitplatform.blob.core.windows.net/one-of-each/file.rtf",
      "id": "8ee4ffcc-52cd-473d-a016-b2b478f53933",
      "name": "file",
      "state": "FINISHED",
      "creationDate": "2023-10-18T19:31:43Z",
      "finishedDate": "2023-10-18T19:31:50Z",
      "workflowDuration": "PT5.7076996S",
      "owner": {
        "id": "e409b47b-3ee9-48e9-a766-b3c30247e402"
      }
    },
    {
      "type": "FILE",
      "originalDate": "2023-10-18T19:28:44Z",
      "mimeType": "text/plain",
      "fileType": "DOCUMENT",
      "fileName": "file.txt",
      "fileSize": 46547,
      "masterUri": "redacted",
      "mezzanineUri": "redacted",
      "document": {},
      "collections": [],
      "uri": "https://graphlitplatform.blob.core.windows.net/one-of-each/file.txt",
      "id": "a79948c0-c6b4-40f2-8709-d102f44405f0",
      "name": "file",
      "state": "FINISHED",
      "creationDate": "2023-10-18T19:31:42Z",
      "finishedDate": "2023-10-18T19:32:03Z",
      "workflowDuration": "PT19.4747515S",
      "owner": {
        "id": "e409b47b-3ee9-48e9-a766-b3c30247e402"
      }
    },
    {
      "type": "FILE",
      "originalDate": "2023-10-18T19:28:44Z",
      "mimeType": "text/plain",
      "fileType": "DOCUMENT",
      "fileName": "file.tsv",
      "fileSize": 65,
      "masterUri": "redacted",
      "mezzanineUri": "redacted",
      "document": {},
      "collections": [],
      "uri": "https://graphlitplatform.blob.core.windows.net/one-of-each/file.tsv",
      "id": "a7d735c0-ab64-4a85-9856-92f475ada959",
      "name": "file",
      "state": "ERRORED",
      "creationDate": "2023-10-18T19:31:42Z",
      "finishedDate": "2023-10-18T19:32:01Z",
      "owner": {
        "id": "e409b47b-3ee9-48e9-a766-b3c30247e402"
      }
    },
    {
      "type": "FILE",
      "originalDate": "2023-10-18T19:28:44Z",
      "mimeType": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
      "fileType": "DOCUMENT",
      "fileName": "file.xlsx",
      "fileSize": 146419,
      "masterUri": "redacted",
      "mezzanineUri": "redacted",
      "document": {
        "title": "Competitive Intelligence",
        "author": "Kirk Marple",
        "keywords": [
          "Product"
        ]
      },
      "collections": [],
      "uri": "https://graphlitplatform.blob.core.windows.net/one-of-each/file.xlsx",
      "id": "f37113dc-fcf6-49ab-b90a-a9026e7bd076",
      "name": "file",
      "state": "INDEXED",
      "creationDate": "2023-10-18T19:31:38Z",
      "owner": {
        "id": "e409b47b-3ee9-48e9-a766-b3c30247e402"
      }
    },
    {
      "type": "FILE",
      "originalDate": "2022-04-04T17:44:00Z",
      "mimeType": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
      "fileType": "DOCUMENT",
      "fileName": "file.docx",
      "fileSize": 22591,
      "masterUri": "redacted",
      "mezzanineUri": "redacted",
      "document": {
        "author": "Dan Hedges"
      },
      "collections": [],
      "uri": "https://graphlitplatform.blob.core.windows.net/one-of-each/file.docx",
      "id": "aa4f0667-9d78-4013-985c-84c584144834",
      "name": "file",
      "state": "FINISHED",
      "creationDate": "2023-10-18T19:31:43Z",
      "finishedDate": "2023-10-18T19:32:03Z",
      "workflowDuration": "PT18.8552063S",
      "owner": {
        "id": "e409b47b-3ee9-48e9-a766-b3c30247e402"
      }
    },
    {
      "type": "FILE",
      "originalDate": "2020-07-31T10:39:27Z",
      "mimeType": "application/pdf",
      "fileType": "DOCUMENT",
      "fileName": "file.pdf",
      "fileSize": 521054,
      "masterUri": "redacted",
      "mezzanineUri": "redacted",
      "document": {
        "author": "Adobe InDesign 15.1 (Macintosh)",
        "pageCount": 5
      },
      "collections": [],
      "uri": "https://graphlitplatform.blob.core.windows.net/one-of-each/file.pdf",
      "id": "fa4df19f-3266-4ad7-bef0-5fe28f82449e",
      "name": "file",
      "state": "FINISHED",
      "creationDate": "2023-10-18T19:31:43Z",
      "finishedDate": "2023-10-18T19:32:17Z",
      "workflowDuration": "PT33.1842026S",
      "owner": {
        "id": "e409b47b-3ee9-48e9-a766-b3c30247e402"
      }
    },
    {
      "type": "FILE",
      "originalDate": "2010-09-10T15:16:19Z",
      "mimeType": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
      "fileType": "DOCUMENT",
      "fileName": "file.pptx",
      "fileSize": 3587664,
      "masterUri": "redacted",
      "mezzanineUri": "redacted",
      "document": {
        "title": "Slide 1",
        "author": "ddivine"
      },
      "collections": [],
      "uri": "https://graphlitplatform.blob.core.windows.net/one-of-each/file.pptx",
      "id": "e5585148-b2f6-43ec-9d13-8fa030fc441d",
      "name": "file",
      "state": "FINISHED",
      "creationDate": "2023-10-18T19:31:43Z",
      "finishedDate": "2023-10-18T19:32:29Z",
      "workflowDuration": "PT45.1066415S",
      "owner": {
        "id": "e409b47b-3ee9-48e9-a766-b3c30247e402"
      }
    }
  ],
  "facets": [
    {
      "facet": "FILE_TYPE",
      "type": "VALUE",
      "value": "Document",
      "count": 9
    },
    {
      "facet": "ORIGINAL_DATE",
      "type": "VALUE",
      "value": "2010-09-01T07:00:00.000Z",
      "count": 1
    },
    {
      "facet": "ORIGINAL_DATE",
      "type": "VALUE",
      "value": "2020-07-01T07:00:00.000Z",
      "count": 1
    },
    {
      "facet": "ORIGINAL_DATE",
      "type": "VALUE",
      "value": "2022-04-01T07:00:00.000Z",
      "count": 1
    },
    {
      "facet": "ORIGINAL_DATE",
      "type": "VALUE",
      "value": "2023-10-01T07:00:00.000Z",
      "count": 6
    },
    {
      "facet": "CONTENT_TYPE",
      "type": "VALUE",
      "value": "File",
      "count": 9
    }
  ]
}

Query Only Facets

Faceted results are also available without returning any content results.

If you assign the limit property to zero, Graphlit will return just the faceted results.

This can be useful for generating charts or histograms of the data that has been ingested into your project or tenant.

Query:

query QueryContents($filter: ContentFilter!, $facets: [ContentFacetInput]) {
  contents(filter: $filter, facets: $facets) {
    results {
      id
    }
    facets {
      facet
      count
      type
      value
      range {
        from
        to
      }
      observable {
        type
        observable {
          id
          name
        }
      }
    }
  }
}

Variables:

{
  "filter": {
    "offset": 0,
    "limit": 0
  },
  "facets": [
    {
      "facet": "ORIGINAL_DATE",
      "timeInterval": "MONTH",
      "timeOffset": -7
    },
    {
      "facet": "CONTENT_TYPE"
    },
    {
      "facet": "FILE_TYPE"
    }
  ]
}

Response:

{
  "results": [],
  "facets": [
    {
      "facet": "FILE_TYPE",
      "type": "VALUE",
      "value": "Document",
      "count": 119
    },
    {
      "facet": "FILE_TYPE",
      "type": "VALUE",
      "value": "Audio",
      "count": 2
    },
    {
      "facet": "FILE_TYPE",
      "type": "VALUE",
      "value": "Image",
      "count": 2
    },
    {
      "facet": "FILE_TYPE",
      "type": "VALUE",
      "value": "Video",
      "count": 2
    },
    {
      "facet": "FILE_TYPE",
      "type": "VALUE",
      "value": "Animation",
      "count": 1
    },
    {
      "facet": "FILE_TYPE",
      "type": "VALUE",
      "value": "Data",
      "count": 1
    },
    {
      "facet": "FILE_TYPE",
      "type": "VALUE",
      "value": "Drawing",
      "count": 1
    },
    {
      "facet": "FILE_TYPE",
      "type": "VALUE",
      "value": "Unknown",
      "count": 1
    },
    {
      "facet": "ORIGINAL_DATE",
      "type": "VALUE",
      "value": "2010-09-01T07:00:00.000Z",
      "count": 1
    },
    {
      "facet": "ORIGINAL_DATE",
      "type": "VALUE",
      "value": "2019-11-01T07:00:00.000Z",
      "count": 1
    },
    {
      "facet": "ORIGINAL_DATE",
      "type": "VALUE",
      "value": "2019-12-01T07:00:00.000Z",
      "count": 1
    },
    {
      "facet": "ORIGINAL_DATE",
      "type": "VALUE",
      "value": "2020-07-01T07:00:00.000Z",
      "count": 1
    },
    {
      "facet": "ORIGINAL_DATE",
      "type": "VALUE",
      "value": "2022-04-01T07:00:00.000Z",
      "count": 1
    },
    {
      "facet": "ORIGINAL_DATE",
      "type": "VALUE",
      "value": "2022-05-01T07:00:00.000Z",
      "count": 1
    },
    {
      "facet": "ORIGINAL_DATE",
      "type": "VALUE",
      "value": "2023-08-01T07:00:00.000Z",
      "count": 22
    },
    {
      "facet": "ORIGINAL_DATE",
      "type": "VALUE",
      "value": "2023-09-01T07:00:00.000Z",
      "count": 54
    },
    {
      "facet": "ORIGINAL_DATE",
      "type": "VALUE",
      "value": "2023-10-01T07:00:00.000Z",
      "count": 37
    },
    {
      "facet": "CONTENT_TYPE",
      "type": "VALUE",
      "value": "Message",
      "count": 100
    },
    {
      "facet": "CONTENT_TYPE",
      "type": "VALUE",
      "value": "File",
      "count": 19
    },
    {
      "facet": "CONTENT_TYPE",
      "type": "VALUE",
      "value": "Page",
      "count": 10
    }
  ]
}

Last updated