POST
/
rest
/
api
/
v1
/
getdocumentsbyfacets
from glean import Glean, models
import os


with Glean(
    api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as g_client:

    res = g_client.client.documents.retrieve_by_facets(request={
        "filter_sets": [
            {
                "filters": [
                    {
                        "field_name": "type",
                        "values": [
                            {
                                "value": "Spreadsheet",
                                "relation_type": models.RelationType.EQUALS,
                            },
                            {
                                "value": "Presentation",
                                "relation_type": models.RelationType.EQUALS,
                            },
                        ],
                    },
                ],
            },
            {
                "filters": [
                    {
                        "field_name": "type",
                        "values": [
                            {
                                "value": "Spreadsheet",
                                "relation_type": models.RelationType.EQUALS,
                            },
                            {
                                "value": "Presentation",
                                "relation_type": models.RelationType.EQUALS,
                            },
                        ],
                    },
                ],
            },
        ],
    })

    # Handle response
    print(res)
{
  "documents": [
    {
      "id": "<string>",
      "datasource": "<string>",
      "connectorType": "API_CRAWL",
      "docType": "<string>",
      "content": {
        "fullTextList": [
          "<string>"
        ]
      },
      "containerDocument": {},
      "parentDocument": {},
      "title": "<string>",
      "url": "<string>",
      "metadata": {
        "container": "container",
        "parentId": "JIRA_EN-1337",
        "createTime": "2000-01-23T04:56:07.000Z",
        "datasource": "datasource",
        "author": {
          "name": "name"
        },
        "documentId": "documentId",
        "updateTime": "2000-01-23T04:56:07.000Z",
        "mimeType": "mimeType",
        "objectType": "Feature Request",
        "components": [
          "Backend",
          "Networking"
        ],
        "status": [
          "Done"
        ],
        "customData": {
          "someCustomField": "someCustomValue"
        }
      },
      "sections": [
        {
          "title": "<string>",
          "url": "<string>"
        }
      ]
    }
  ],
  "hasMoreResults": true,
  "cursor": "<string>"
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

Information about facet conditions for documents to be retrieved.

The body is of type object.

Response

200
application/json

OK

The response is of type object.