--- title: "Building a Document Export Query" slug: "creating-a-document-export-query-with-configurable-joins" updated: 2026-04-03T22:17:48Z published: 2026-04-03T22:17:48Z canonical: "knowledge.technolutions.net/creating-a-document-export-query-with-configurable-joins" --- > ## Documentation Index > Fetch the complete documentation index at: https://knowledge.technolutions.net/llms.txt > Use this file to discover all available pages before exploring further. # Building a Document Export Query To [export documents](/v1/docs/getting-started-with-document-exports) from Slate, you’ll create a query that returns one row per document. You can use filters to limit the documents that are returned by this query. > [!NOTE] > 💼 Don’t want to start from scratch? > > Copy this [Suitcase](/docs/suitcase-import) ID and paste it in **Database → Suitcase Import** to import a pre-made example document export query. > > ```SuitcaseID > 97b20e37-b617-4b79-95d9-999503cf24e7:slate-examples > ``` > > Optionally, continue to [adding metadata](/v1/docs/creating-a-document-export-query-with-configurable-joins#adding-metadata) and [customizing file names](/v1/docs/creating-a-document-export-query-with-configurable-joins#customizing-file-names). > > When satisfied with the query, proceed to [Scheduling Document Exports](/v1/docs/scheduling-document-exports). ## Creating the query 1. Go to **Queries / Reports.** 2. Select **New Query.** 3. Configure the following settings: - **Name:** Enter a name for the query. - **Folder:** Select an existing folder, or select *Other* to create a new one. - **Type**: Configurable Joins - **Category**: Related - **Base**: Document [![Configure_New_Query_Settings.png](https://cdn.us.document360.io/cd8ea7a6-07f3-4846-a554-627ac016d3e3/Images/Documentation/configure_new_query_settings.png)](https://cdn.us.document360.io/cd8ea7a6-07f3-4846-a554-627ac016d3e3/Images/Documentation/configure_new_query_settings.png) 4. Select **Save.** 5. Select **Edit Properties.** 6. Configure the following settings: - **Limit Rows**: There is a strict limit of 5,000 documents per query execution, so this must be a value of 5,000 or less. - **Execution Options**: Retrieve only the new records since the query was last run - 📖 [More on query execution options](/v1/docs/data-export#the-different-ways-queries-can-return-records) - **Fetch Behavior**: Preserve where clause on fetch if required by one or more filters. - **Queue**: None (default) - [Queues](/v1/docs/query-settings#queue) can’t be used with a document export. - Do not adjust this setting. - **Secondary Key**: Paste the following: ```plaintext doc__JID_.[stream] ``` ![](https://cdn.us.document360.io/cd8ea7a6-07f3-4846-a554-627ac016d3e3/Images/Documentation/Edit Properties Settings - Secondary Key.png) 7. Select **Save.** ## Adding required exports To create a document export query, you must include the direct exports `pdf:xml` and `pdf:file`: - `pdf:xml`**:** Specifies the file data to export - `pdf:file`: Determines the filename To add these exports to the query: 1. Select **Export.** 2. Select `pdf:file` and `pdf:xml`. [![Exports_-_pdf-xml__pdf-file.png](https://cdn.us.document360.io/cd8ea7a6-07f3-4846-a554-627ac016d3e3/Images/Documentation/exports_-_pdf-xml__pdf-file.png)](https://cdn.us.document360.io/cd8ea7a6-07f3-4846-a554-627ac016d3e3/Images/Documentation/exports_-_pdf-xml__pdf-file.png) 3. Select **Continue.** 4. Select **Rename Exports**. 5. For both exports, remove the preceding `Document `. The exports must be named `pdf:file` and `pdf:xml`. [![Rename_Exports.png](https://cdn.us.document360.io/cd8ea7a6-07f3-4846-a554-627ac016d3e3/Images/Documentation/rename_exports.png)](https://cdn.us.document360.io/cd8ea7a6-07f3-4846-a554-627ac016d3e3/Images/Documentation/rename_exports.png) 6. Select **Save**. ## Adding metadata You can add metadata to your exported documents by recreating the `pdf:xml` direct export as a subquery export. 📖 [Adding a Header or Footer to Documents in a Document Export Query](/v1/docs/adding-a-header-or-footer-to-documents-in-a-document-export-query) ## Customizing file names Slate generates unique file names for exported documents using the `pdf:file` direct export. You can customize the file name scheme by recreating `pdf:file` as a subquery export. 📖 [Customizing the document file name in a document export query](/v1/docs/customizing-the-document-file-name-in-a-document-export-query) ## ➡️ Next up: Scheduling the document export Your next step is to configure the query’s **schedule export settings**, which define the format of the exported files. > [!NOTE] > ➡️ [Scheduling document exports](/v1/docs/scheduling-document-exports)