Docs: update metadata

This commit is contained in:
AllenWriter
2025-03-17 16:41:37 +08:00
parent 8710920c45
commit 8c7dfe0f0c
8 changed files with 369 additions and 584 deletions

View File

@@ -174,7 +174,7 @@
"en-us/user-guide/knowledge-base/integrate-knowledge-within-application",
"en-us/user-guide/knowledge-base/retrieval-test-and-citation",
"en-us/user-guide/knowledge-base/connect-external-knowledge-base",
"en-us/user-guide/knowledge-base/api-documentation/external-knowledge-api-documentation"
"en-us/user-guide/knowledge-base/external-knowledge-api"
]
},
{

View File

@@ -29,7 +29,7 @@ Use **Metadata Filtering** to refine document search in your knowledge base. For
It's possible to modify the indexing strategy and retrieval mode for an individual knowledge base within the node. For a detailed explanation of these settings, refer to the knowledge base [documentation](/en-us/user-guide/knowledge-base/knowledge-base-creation/introduction).
![](https://assets-docs.dify.ai/2025/03/4ce088c4caadec0f68627cd6a17be4b4.png)
![](https://assets-docs.dify.ai/2025/03/fbd43d558f83b355a1b18ac26a253b84.png)
Dify offers two recall strategies for different knowledge base retrieval scenarios: "N-to-1 Recall" and "Multi-way Recall". In the N-to-1 mode, knowledge base queries are executed through function calling, requiring the selection of a system reasoning model. In the multi-way recall mode, a Rerank model needs to be configured for result re-ranking. For a detailed explanation of these two recall strategies, refer to the retrieval mode explanation in the [help documentation](https://docs.dify.ai/guides/knowledge-base/create-knowledge-and-upload-documents#id-5-indexing-methods).

View File

@@ -26,6 +26,7 @@ The request accepts the following data in JSON format.
| knowledge_id | TRUE | string | Your knowledge's unique ID | AAA-BBB-CCC |
| query | TRUE | string | User's query | What is Dify? |
| retrieval_setting | TRUE | object | Knowledge's retrieval parameters | See below |
| metadata_condition | Yes | Object | Original array filtering | See below |
The `retrieval_setting` property is an object containing the following keys:
@@ -34,6 +35,40 @@ The `retrieval_setting` property is an object containing the following keys:
| top_k | TRUE | int | Maximum number of retrieved results | 5 |
| score_threshold | TRUE | float | The score limit of relevance of the result to the query, scope: 0~1 | 0.5 |
The `metadata_condition` property is an object containing the following keys:
| Attribute | Required | Type | Description | Example Value |
|-----------|----------|------|-------------|--------------|
| logical_operator | No | String | Logical operator, values can be `and` or `or`, default is `and` | and |
| conditions | Yes | Array (Object) | List of conditions | See below |
Each object in the `conditions` array contains the following keys:
| Attribute | Required | Type | Description | Example Value |
|-----------|----------|------|-------------|--------------|
| name | Yes | Array (String) | Names of the metadata to filter | `["category", "tag"]` |
| comparison_operator | Yes | String | Comparison operator | `contains` |
| value | No | String | Comparison value, can be omitted when the operator is `empty`, `not empty`, `null`, or `not null` | `"AI"` |
Supported `comparison_operator` Operators
- `contains`: Contains a certain value
- `not contains`: Does not contain a certain value
- `start with`: Starts with a certain value
- `end with`: Ends with a certain value
- `is`: Equals a certain value
- `is not`: Does not equal a certain value
- `empty`: Is empty
- `not empty`: Is not empty
- `=`: Equals
- `≠`: Not equal
- `>`: Greater than
- `<`: Less than
- `≥`: Greater than or equal to
- `≤`: Less than or equal to
- `before`: Before a certain date
- `after`: After a certain date
## Request Syntax
```json

View File

@@ -85,13 +85,13 @@ The **Knowledge Retrieval** node allows you to filter documents using metadata f
> Note: Automatic Mode requires model selection for document retrieval.
![model_selection](https://assets-docs.dify.ai/2025/03/3d4ca70e3340d98d0f9824958c667def.png)
![model_selection](https://assets-docs.dify.ai/2025/03/fe387793ad9923660f9f9470aacff01b.png)
- **Manual:** Configure filters manually.
![](https://assets-docs.dify.ai/2025/03/ec6329e265e035e3a0d6941c9313a19d.png)
2. *(Optional)* For Manual Mode, follow these steps:
2. For Manual Mode, follow these steps:
1. Click **Conditions** to open the configuration panel.
@@ -104,7 +104,7 @@ The **Knowledge Retrieval** node allows you to filter documents using metadata f
![add_condition](https://assets-docs.dify.ai/2025/03/72678c4174f753f306378b748fbe6635.png)
3. *(Optional)* Click **+Add Condition** to add more fields.
3. Click **+Add Condition** to add more fields.
![add_more_fields](https://assets-docs.dify.ai/2025/03/aeb518c40aabdf467c9d2c23016d0a16.png)
@@ -122,10 +122,12 @@ The **Knowledge Retrieval** node allows you to filter documents using metadata f
| | ends with | Matches text at end. Example: `ends with "2024"` returns "Report 2024", "Summary 2024", etc. |
| Number | = | Exact number match. Example: `= 10` returns documents marked with exactly 10. |
| | ≠ | Excludes specific number. Example: `≠ 5` returns all documents except those marked with 5. |
| | `>` | Greater than. Example: `> 100` returns documents with values above 100. |
| | `<` | Less than. Example: `< 50` returns documents with values below 50. |
| | &gt; | Greater than. Example: `&gt; 100` returns documents with values above 100. |
| | &lt; | Less than. Example: `&lt; 50` returns documents with values below 50. |
| | ≥ | Greater than or equal to. Example: `≥ 20` returns documents with values 20 or higher. |
| | ≤ | Less than or equal to. Example: `≤ 200` returns documents with values 200 or lower. |
| | is empty | Field has no value assigned. For example, `is empty` returns all documents where this field has no number assigned. |
| | is not empty | Field has a value assigned. For example, `is not empty` returns all documents where this field has a number assigned. |
| Date | is | Exact date match. Example: `is "2024-01-01"` returns documents dated January 1, 2024. |
| | before | Prior to date. Example: `before "2024-01-01"` returns documents dated before January 1, 2024. |
| | after | After date. Example: `after "2024-01-01"` returns documents dated after January 1, 2024. |

View File

@@ -6,45 +6,41 @@ title: Metadata
### Overview
Metadata is information that describes your data - essentially data about data. Just as a book has a table of contents to help you understand its structure, metadata provides context about your datas content, origin, purpose, etc., making it easier for you to find and manage information in your knowledge base.
Metadata is information that describes your data - essentially "data about data". Just as a book has a table of contents to help you understand its structure, metadata provides context about your data's content, origin, purpose, etc., making it easier for you to find and manage information in your knowledge base.
This guide aims to help you understand metadata and effectively manage your knowledge base.
### Core Concepts
- **Metadata Field:** The container for specific information about a document. Think of it as a labeled box where you store particular details about your content.
- **Field:** The label of a metadata field (e.g., "author", "language").
- **Value Count:** The number of unique values contained in a metadata field.
- **Value:** The information stored in a metadata field (e.g., "Jack", "English").
<img
src="https://assets-docs.dify.ai/2025/03/330f26e90438cf50167c4cb6ce30e458.png"
width="300"
className="mx-auto"
alt="metadata_field"
src="https://assets-docs.dify.ai/2025/03/b6a197aa21ab92db93869fcbfa156b62.png"
width="300"
alt="field_name_and_value"
/>
- **Field Name:** The label of a metadata field (e.g., “author”, “language”).
- **Value:** The information stored in a metadata field (e.g., “Jack”, “English”).
- **Value Count:** The number of values contained in a metadata fieldincluding duplicates. (e.g., "3").
<img
src="https://assets-docs.dify.ai/2025/03/b6a197aa21ab92db93869fcbfa156b62.png"
width="300"
className="mx-auto"
alt="metadata_field"
src="https://assets-docs.dify.ai/2025/03/330f26e90438cf50167c4cb6ce30e458.png"
width="300"
className="mx-auto"
alt="metadata_field"
/>
- **Value Type:** The type of value a field can contain.
- Dify supports three value types:
- String: For text-based information
- Number: For numerical data
- Time: For dates/timestamps
- Dify supports three value types:
- String: For text-based information
- Number: For numerical data
- Time: For dates/timestamps
<img
src="https://assets-docs.dify.ai/2025/03/c208291ea8abae500819d195c2d52d65.png"
width="300"
className="mx-auto"
alt="metadata_field"
src="https://assets-docs.dify.ai/2025/03/f6adc7418869334805361535c8cd6874.png"
width="300"
alt="value_type"
/>
## How to Manage My Metadata?
@@ -65,113 +61,17 @@ To access the Metadata Panel, go to **Knowledge Base** page and click **Metadata
![metadata_panel](https://assets-docs.dify.ai/2025/03/6000c85b5d2e29a2a5af5e0a047a7a59.png)
##### Work with the Metadata Panel
- **View Metadata:** Browse built-in and custom metadata. **Built-in Metadata** is system-generated; **Custom Metadata** is user-defined.
- **Add Metadata Fields:** Create new metadata fields by clicking **+Add Metadata**.
- **Edit Metadata Fields:** Modify field names by clicking the edit icon next to each field.
- **Delete Metadata Fields:** delete unwanted fields by clicking the the delete icon next to each field.
##### Benefits
**Metadata panel** centralizes field management, making it easy to organize and find documents through customizable labels.
##### Built-in vs Custom Metadata
<table>
<thead>
<tr>
<th>Feature</th>
<th>Built-in Metadata</th>
<th>Custom Metadata</th>
</tr>
</thead>
<tbody>
<tr>
<td>Location</td>
<td>Lower section of the Metadata panel</td>
<td>Upper section of the Metadata panel</td>
</tr>
<tr>
<td>Example</td>
<td align="center">
<img
src="https://assets-docs.dify.ai/2025/03/5d03e958ed936badf4eb1ca955372c8b.png"
alt="Built-in metadata example"
width="150"
/>
</td>
<td align="center">
<img
src="https://assets-docs.dify.ai/2025/03/692a2824501f4e2f5fcc016e27159859.png"
alt="Custom metadata example"
width="150"
/>
</td>
</tr>
<tr>
<td>Activation</td>
<td>Disabled by default; requires manual activation</td>
<td>Add as needed</td>
</tr>
<tr>
<td>Generation</td>
<td>System automatically extracts and generates field values</td>
<td>User-defined and manually added</td>
</tr>
<tr>
<td>Editing</td>
<td>Fields and values cannot be modified once generated</td>
<td>Fields and values can be edited or deleted</td>
</tr>
<tr>
<td>Scope</td>
<td>Applies to all existing and new documents when enabled</td>
<td>Stored in metadata list; requires manual assignment to documents</td>
</tr>
<tr>
<td>Fields</td>
<td>
System-defined fields include:
<ul>
<li>Original filename (string)</li>
<li>Uploader (string)</li>
<li>Upload date (time)</li>
<li>Last update date (time)</li>
<li>Source (string)</li>
</ul>
</td>
<td>No default fields; all fields must be manually created</td>
</tr>
<tr>
<td>Value Types</td>
<td>
Three supported value types:
<ul>
<li>String: For text values</li>
<li>Number: For numerical values</li>
<li>Time: For dates and timestamps</li>
</ul>
</td>
<td>
Three supported value types:
<ul>
<li>String: For text values</li>
<li>Number: For numerical values</li>
<li>Time: For dates and timestamps</li>
</ul>
</td>
</tr>
<tr>
<td>Use Cases</td>
<td>Stores basic document information (filename, uploader, dates)</td>
<td>Supports business-specific needs (security levels, tags, categories)</td>
</tr>
</tbody>
</table>
| Feature | Built-in Metadata | Custom Metadata |
| --- | --- | --- |
| Location | Lower section of the Metadata panel | Upper section of the Metadata panel |
| Activation | Disabled by default; requires manual activation | Add as needed |
| Generation | System automatically extracts and generates field values | User-defined and manually added |
| Editing | Fields and values cannot be modified once generated | Fields and values can be edited or deleted |
| Scope | Applies to all existing and new documents when enabled | Stored in metadata list; requires manual assignment to documents |
| Fields | System-defined fields include:<br>• document_name (string)<br>• uploader (string)<br>• upload_date (time)<br>• last_update_date (time)<br>• source (string) | No default fields; all fields must be manually created |
| Value Types | • String: For text values<br>• Number: For numerical values<br>• Time: For dates and timestamps | • String: For text values<br>• Number: For numerical values<br>• Time: For dates and timestamps |
#### Create New Metadata Fields
@@ -181,26 +81,20 @@ To create a new metadata field:
![new_metadata](https://assets-docs.dify.ai/2025/03/5086db42c40be64e54926b645c38c9a0.png)
2. Choose the value type:
- String (for text)
- Number (for numerical values)
- Time (for dates/timestamps)
2. Choose the value type.
3. Name the field.
> Naming rules: Use lowercase letters, numbers, and underscores only.
<img
src="https://assets-docs.dify.ai/2025/03/24e85f14d4c7c3bcade25a7abfc15467.png"
width="300"
className="mx-auto"
alt="metadata_field"
src="https://assets-docs.dify.ai/2025/03/f6adc7418869334805361535c8cd6874.png"
width="300"
alt="value_type"
/>
4. Click **Save** to apply changes.
> Note: New fields are automatically available across all documents in your knowledge base.
![save_field](https://assets-docs.dify.ai/2025/03/f44114cc58d4ba11ba60adb2d04c9b4c.png)
#### Edit Metadata Fields
@@ -216,14 +110,15 @@ To edit a metadata field:
> Note: You can only modify the field name, not the value type.
<img
src="https://assets-docs.dify.ai/2025/03/216ec7d9227bb7b2a199c1bd5d3d812c.png"
width="300"
className="mx-auto"
alt="metadata_field"
src="https://assets-docs.dify.ai/2025/03/2f814f725df9aeb1a0048e51d736d969.png"
width="350"
alt="rename_field_2"
/>
3. Click **Save** to apply changes.
> Note: Field changes update across all related documents in your knowledge base.
![same_renamed_field](https://assets-docs.dify.ai/2025/03/022e42c170b40c35622b9b156c8cc159.png)
#### Delete Metadata Fields
@@ -240,9 +135,7 @@ To delete a metadata field, click the delete icon next to a field to delete it.
You can edit metadata in bulk in the knowledge base.
##### Get Started with the Metadata Editor
###### Access the Metadata Editor
##### Access the Metadata Editor
To access the Metadata Editor:
@@ -254,58 +147,51 @@ To access the Metadata Editor:
![edit_metadata](https://assets-docs.dify.ai/2025/03/719f3c31498f23747fed7d7349fd64ba.png)
###### Work with the Metadata Editor
- **View Metadata:** The editor shows existing metadata in the upper section and new metadata in the lower section.
<Info>
Field status is indicated by:
No marker: Unchanged.
Blue dot: Modified.
Reset option: Appears on hover over the blue dot.
</Info>
- **Edit Values:** Modify values in the field box.
<Info>
Single values show directly in the field box.
Multiple values show as a “Multiple Values” card. If you delete all values, the box will show “Empty”.
</Info>
- **Add Fields:** Click **+Add Metadata** to **create new fields**, **add existing fields** and **manage all fields**.
- **Delete Fields:** Click the delete icon to delete a field from selected documents.
- **Set Update Scope:** Choose whether to apply changes to all selected documents.
##### Bulk Add Metadata
To add metadata in bulk:
1. Click **+Add Metadata** in the editor to:
![add_metadata](https://assets-docs.dify.ai/2025/03/868f51bbd6893e32bf23952c6d0aa079.png)
- Create new fields via **+New Metadata**.
> New fields are automatically added to the knowledge base.
![new_metadata_field](https://assets-docs.dify.ai/2025/03/e32211f56421f61b788943ba40c6959e.png)
<img
src="https://assets-docs.dify.ai/2025/03/d4e4f87447c3e445d5b7507df1126c7b.png"
width="400"
alt="add_metadata"
/>
- Add existing fields from the dropdown or from the search box.
- Add existing fields from the dropdown or from the search box.
![existing_field](https://assets-docs.dify.ai/2025/03/ea9aab2c4071bf2ec75409b05725ac1f.png)
<img
src="https://assets-docs.dify.ai/2025/03/ea9aab2c4071bf2ec75409b05725ac1f.png"
width="400"
alt="existing_field"
/>
- Access the Metadata Panel to manage metadata fields via **Manage**.
- Create new fields via **+New Metadata**.
> New fields are automatically added to the knowledge base.
![manage_field](https://assets-docs.dify.ai/2025/03/82561edeb747b100c5295483c6238ffa.png)
<img
src="https://assets-docs.dify.ai/2025/03/e32211f56421f61b788943ba40c6959e.png"
width="400"
alt="new_metadata_field"
/>
- Access the Metadata Panel to manage metadata fields via **Manage**.
<img
src="https://assets-docs.dify.ai/2025/03/82561edeb747b100c5295483c6238ffa.png"
width="400"
alt="manage_field"
/>
2. *(Optional)* Enter values for new fields.
![value_for_field](https://assets-docs.dify.ai/2025/03/34c77cbf60fa524456aa8f3df8d7a576.png)
![value_for_field](https://assets-docs.dify.ai/2025/03/aabfe789f607a1db9062beb493213376.png)
> The date picker is for time-type fields.
![date_picker](https://assets-docs.dify.ai/2025/03/8c991925c204703a4dceab42a23d684e.png)
![date_picker](https://assets-docs.dify.ai/2025/03/65df828e605ebfb4947fccce189520a3.png)
3. Click **Save** to apply changes.
@@ -314,18 +200,34 @@ To add metadata in bulk:
To update metadata in bulk:
1. In the editor:
- **Add Values:** Type directly in the field boxes.
- **Reset Values:** Click the blue dot that appears on hover.
![reset_values](https://assets-docs.dify.ai/2025/03/01c0cde5a6eafa48e1c6e5438fc2fa6b.png)
- **Add Values:** Type directly in the field boxes.
- **Delete Values:** Clear the field or delete the **Multiple Value** card.
![multiple_values](https://assets-docs.dify.ai/2025/03/9cea5f8d4e2f1fb5bbd4812c875210f4.png)
- **Reset Values:** Click the blue dot that appears on hover.
- **Delete fields:** Click the delete icon (fields appear struck through and grayed out).
> Note: This only deletes the field from this document, not from your knowledge base.
<img
src="https://assets-docs.dify.ai/2025/03/01c0cde5a6eafa48e1c6e5438fc2fa6b.png"
width="400"
alt="reset_values"
/>
![delete_fields](https://assets-docs.dify.ai/2025/03/ed8c9143ba9a8eae6efcb76e309dbec1.png)
- **Delete Values:** Clear the field or delete the **Multiple Value** card.
<img
src="https://assets-docs.dify.ai/2025/03/5c4323095644d2658881b783246914f1.png"
width="400"
alt="multiple_values"
/>
- **Delete fields:** Click the delete icon (fields appear struck through and grayed out).
> Note: This only deletes the field from this document, not from your knowledge base.
<img
src="https://assets-docs.dify.ai/2025/03/1b0318b898f951e307e3dc8cdc2f48d3.png"
width="400"
alt="delete_fields"
/>
2. Click **Save** to apply changes.
@@ -337,15 +239,19 @@ Use **Apply to All Documents** to control changes:
- **Checked**: Adds or updates fields across all selected documents.
![apply_all_changes](https://assets-docs.dify.ai/2025/03/4f95cdd2daef1cdbc63f8e249da71f1c.png)
<img
src="https://assets-docs.dify.ai/2025/03/4550c68960802c24271492b63a39ad05.png"
width="400"
alt="apply_all_changes"
/>
#### Edit Metadata on the Document Details Page
You can edit a single documents metadata on its details page.
You can edit a single document's metadata on its details page.
##### Access Metadata Edit Mode
To edit a single documents metadata:
To edit a single document's metadata:
On the document details page, click **Start labeling** to begin editing.
@@ -355,24 +261,24 @@ On the document details page, click **Start labeling** to begin editing.
##### Add Metadata
To add a single documents metadata fields and values:
To add a single document's metadata fields and values:
1. Click **+Add Metadata** to:
![add_metadata](https://assets-docs.dify.ai/2025/03/f9ba9b10bbcf6eaca787eed4fcde44da.png)
- Create new fields via **+New Metadata**.
- Create new fields via **+New Metadata**.
> New fields are automatically added to the knowledge base.
![new_fields](https://assets-docs.dify.ai/2025/03/739e7e51436259fca45d16065509fabb.png)
- Add existing fields from the dropdown or from the search box.
> New fields are automatically added to the knowledge base.
![new_fields](https://assets-docs.dify.ai/2025/03/739e7e51436259fca45d16065509fabb.png)
- Add existing fields from the dropdown or from the search box.
![existing_fields](https://assets-docs.dify.ai/2025/03/5b1876e8bc2c880b3b774c97eba371ab.png)
![existing_fields](https://assets-docs.dify.ai/2025/03/5b1876e8bc2c880b3b774c97eba371ab.png)
- Access the Metadata Panel via **Manage**.
- Access the Metadata Panel via **Manage**.
![manage_metadata](https://assets-docs.dify.ai/2025/03/8dc74a1d2cdd87294e58dbc3d6dd161b.png)
![manage_metadata](https://assets-docs.dify.ai/2025/03/8dc74a1d2cdd87294e58dbc3d6dd161b.png)
2. *(Optional)* Enter values for new fields.
@@ -382,20 +288,20 @@ To add a single documents metadata fields and values:
##### Edit Metadata
To update a single documents metadata fields and values:
To update a single document's metadata fields and values:
1. Click **Edit** in the top right to begin editing.
![edit_mode](https://assets-docs.dify.ai/2025/03/bb33a0f9c6980300c0f979f8dc0d274d.png)
2. Edit metadata:
- **Update Values:** Type directly in value fields or delete it.
- **Update Values:** Type directly in value fields or delete it.
> Note: You can only modify the value, not the value name.
- **Delete Fields:** Click the delete icon.
> Note: You can only modify the value, not the value name.
- **Delete Fields:** Click the delete icon.
> Note: This only deletes the field from this document, not from your knowledge base.
> Note: This only deletes the field from this document, not from your knowledge base.
![edit_metadata](https://assets-docs.dify.ai/2025/03/4c0c4d83d3ad240568f316abfccc9c2c.png)
@@ -413,82 +319,25 @@ See *[Maintaining Dataset via API](https://docs.dify.ai/guides/knowledge-base/kn
- **What can I do with metadata?**
- Find information faster with smart filtering.
- Find information faster with smart filtering.
- Control access to sensitive content.
- Control access to sensitive content.
- Organize data more effectively.
- Organize data more effectively.
- Automate workflows based on metadata rules.
- Automate workflows based on metadata rules.
- **Fields vs Values: What is the difference?**
| Concept | Definition | Characteristics | Examples |
|---|---|---|---|
| --- | --- | --- | --- |
| Metadata Fields in the Metadata Panel | System-defined attributes that describe document properties | Global fields accessible across all documents in the knowledge base | Author, Type, Date, etc. |
| Metadata Value on a document's detail page | Custom metadata tagged according to individual document requirements | Unique metadata values assigned based on document content and context | The "Author" field in Document A is set to "Mary" value, while in Document B it is set to "John" value. |
- **How do different delete options work?**
<table>
<thead>
<tr>
<th>Action</th>
<th>Steps</th>
<th>Image</th>
<th>Impact</th>
<th>Outcome</th>
</tr>
</thead>
<tbody>
<tr>
<td>Delete field in the Metadata Panel</td>
<td>In the Metadata Panel, click delete icon next to field</td>
<td align="center">
<img
src="https://assets-docs.dify.ai/2025/03/13367a865d589a29b7c4098526fad5dc.png"
alt="knowledge_base_delete"
width="150"
/>
</td>
<td>Global - affects all documents</td>
<td>Field and all values permanently deleted from the knowledge base</td>
</tr>
<tr>
<td>Delete field in the Metadata Editor</td>
<td>In the Metadata Editor, click delete icon next to field</td>
<td align="center">
<img
src="https://assets-docs.dify.ai/2025/03/ed8c9143ba9a8eae6efcb76e309dbec1.png"
alt="bulk_delete"
width="150"
/>
</td>
<td>Selected documents only</td>
<td>Field deleted from selected documents; remains in the knowledge base</td>
</tr>
<tr>
<td>Delete field on the document detail page</td>
<td>In the Edit Mode, click delete icon next to field</td>
<td align="center">
<img
src="https://assets-docs.dify.ai/2025/03/19d7fe886dd30a3f3322fa2a87f87203.png"
alt="single_delete"
width="150"
/>
</td>
<td>Current document only</td>
<td>Field deleted from current document; remains in the knowledge base</td>
</tr>
</tbody>
</table>
- **Can I see values in the Metadata Panel?**
The management panel only shows value counts (e.g., "24 values"). Please check the document details page to see specific values.
- **Can I delete a specific value in the Metadata Editor?**
No - bulk edit only deletes all values at once.
To delete a specific value, go to the document details page and follow the steps in **Edit Metadata on the Document Details Page > Edit Metadata**.
| Action | Steps | Image | Impact | Outcome |
| --- | --- | --- | --- | --- |
| Delete field in the Metadata Panel | In the Metadata Panel, click delete icon next to field | ![knowledge_base_delete](https://assets-docs.dify.ai/2025/03/13367a865d589a29b7c4098526fad5dc.png) | Global - affects all documents | Field and all values permanently deleted from the knowledge base |
| Delete field in the Metadata Editor | In the Metadata Editor, click delete icon next to field | ![bulk_delete](https://assets-docs.dify.ai/2025/03/ed8c9143ba9a8eae6efcb76e309dbec1.png) | Selected documents only | Field deleted from selected documents; remains in the knowledge base |
| Delete field on the document detail page | In the Edit Mode, click delete icon next to field | ![single_delete](https://assets-docs.dify.ai/2025/03/19d7fe886dd30a3f3322fa2a87f87203.png) | Current document only | Field deleted from current document; remains in the knowledge base |

View File

@@ -26,6 +26,7 @@ Authorization: Bearer {API_KEY}
| knowledge_id | 是 | 字符串 | 知识库唯一 ID | AAA-BBB-CCC |
| query | 是 | 字符串 | 用户的查询 | Dify 是什么? |
| retrieval_setting | 是 | 对象 | 知识检索参数 | 见下文 |
| metadata_condition | 是 | 对象 | 原数组筛选 | 见下文 |
`retrieval_setting` 属性是一个包含以下键的对象:
@@ -34,6 +35,40 @@ Authorization: Bearer {API_KEY}
| top_k | 是 | 整数 | 检索结果的最大数量 | 5 |
| score_threshold | 是 | 浮点数 | 结果与查询相关性的分数限制范围0~1 | 0.5 |
`metadata_condition` 属性是一个包含以下键的对象:
| 属性 | 是否必需 | 类型 | 描述 | 示例值 |
|------|----------|------|------|--------|
| logical_operator | 否 | 字符串 | 逻辑操作符,取值为 `and` 或 `or`,默认 `and` | and |
| conditions | 是 | 数组(对象) | 条件列表 | 见下文 |
`conditions` 数组中的每个对象包含以下键:
| 属性 | 是否必需 | 类型 | 描述 | 示例值 |
|------|----------|------|------|--------|
| name | 是 | 数组(字符串) | 需要筛选的 metadata 名称 | `["category", "tag"]` |
| comparison_operator | 是 | 字符串 | 比较操作符 | `contains` |
| value | 否 | 字符串 | 对比值,当操作符为 `empty`、`not empty`、`null`、`not null` 时可省略 | `"AI"` |
支持的 `comparison_operator` 操作符:
- `contains`:包含某个值
- `not contains`:不包含某个值
- `start with`:以某个值开头
- `end with`:以某个值结尾
- `is`:等于某个值
- `is not`:不等于某个值
- `empty`:为空
- `not empty`:不为空
- `=`:等于
- `≠`:不等于
- `>`:大于
- `<`:小于
- `≥`:大于等于
- `≤`:小于等于
- `before`:在某个日期之前
- `after`:在某个日期之后
## 请求语法
```json

View File

@@ -90,13 +90,13 @@ Dify 目前支持多个 Rerank 模型,进入 “模型供应商” 页填入 R
> 启用自动模式后,你依然需要在 **模型** 栏中选择合适的大模型以执行文档检索任务。
![model_selection](https://assets-docs.dify.ai/2025/03/3d4ca70e3340d98d0f9824958c667def.png)
![model_selection](https://assets-docs.dify.ai/2025/03/fe387793ad9923660f9f9470aacff01b.png)
- **手动模式**:用户可以手动配置筛选条件,自由设置筛选规则,适用于复杂的筛选需求。
![](https://assets-docs.dify.ai/2025/03/ec6329e265e035e3a0d6941c9313a19d.png)
2. *(可选)* 如果你选择了 **手动模式**,请参照以下步骤配置筛选条件:
2. 如果你选择了 **手动模式**,请参照以下步骤配置筛选条件:
1. 点击 **条件** 按钮,弹出配置框。
@@ -112,7 +112,7 @@ Dify 目前支持多个 Rerank 模型,进入 “模型供应商” 页填入 R
![add_condition](https://assets-docs.dify.ai/2025/03/72678c4174f753f306378b748fbe6635.png)
3. *(可选)* 如果需要添加多条字段,可以重复点击 **+添加条件** 按钮。
3. 如果需要添加多条字段,可以重复点击 **+添加条件** 按钮。
![add_more_fields](https://assets-docs.dify.ai/2025/03/aeb518c40aabdf467c9d2c23016d0a16.png)
@@ -134,6 +134,8 @@ Dify 目前支持多个 Rerank 模型,进入 “模型供应商” 页填入 R
| | &lt; | 字段的值必须小于你输入的数字。例如,`< 50` 会返回所有数字标记为小于 50 的文档。 |
| | ≥ | 字段的值必须大于或等于你输入的数字。例如,`≥ 20` 会返回所有数字标记为大于或等于 20 的文档。 |
| | ≤ | 字段的值必须小于或等于你输入的数字。例如,`≤ 200` 会返回所有数字标记为小于或等于 200 的文档。 |
| | is empty | 字段未设置值。例如,`is empty` 会返回所有该字段未标记数字的文档。 |
| | is not empty | 字段已设置值。例如,`is not empty` 会返回所有该字段已标记数字的文档。 |
| 时间 | is | 字段的时间值必须与你选择的时间完全匹配。例如,`is "2024-01-01"` 只会返回标记为 2024 年 1 月 1 日的文档。 |
| | before | 字段的时间值必须早于你选择的时间。例如,`before "2024-01-01"` 会返回所有标记为 2024 年 1 月 1 日之前的文档。 |
| | after | 字段的时间值必须晚于你选择的时间。例如,`after "2024-01-01"` 会返回所有标记为 2024 年 1 月 1 日之后的文档。 |
@@ -155,7 +157,7 @@ Dify 目前支持多个 Rerank 模型,进入 “模型供应商” 页填入 R
当你输入常量筛选值时,该筛选值必须与该元数据字段值的文本完全一致,系统才能返回该文档。例如,当你设置筛选条件为 `starts with "App"` 或 `contains "App"` 时,系统会返回标记为 “Apple” 的文档,但不会返回标记为 “apple” 或 “APPLE” 的文档。
</Warning>
6. 配置筛选条件之间的逻辑关系 `AND` 或 `OR`,以控制筛选的精确度
6. 配置筛选条件之间的逻辑关系 `AND` 或 `OR`。
- `AND`:当一个文档满足所有筛选条件时,才能检索到该文档。
- `OR`:只要一个文档满足其中任意一个筛选条件,就可以检索到该文档。

View File

@@ -9,41 +9,37 @@ title: 元数据
元数据是用于描述其他数据的信息。简单来说,它是"关于数据的数据"。它就像一本书的目录或标签,可以为你介绍数据的内容、来源和用途。
通过提供数据的上下文,元数据能帮助你在知识库内快速查找和管理数据。
### 其他相关定义
### 知识库元数据定义
- **元数据字段Metadata Field**:元数据字段是用于描述文档特定属性的标识项,每个字段代表文档的某个特征或信息。例如"author"字段用于描述该文档的作者
- **字段(Field**:元数据字段是用于描述文档特定属性的标识项,每个字段代表文档的某个特征或信息。例如"author""language"等
- **字段值计数Value Count**:字段值计数是指在某条元数据字段中不同字段值的数量。例如,此处的"3"是字段值计数,指该字段中有 3 个独特的字段值
- **字段值Value**:字段值是该字段的具体信息或属性,例如"Jack""English"
<img
src="https://assets-docs.dify.ai/2025/03/330f26e90438cf50167c4cb6ce30e458.png"
width="300"
className="mx-auto"
alt="metadata_field"
src="https://assets-docs.dify.ai/2025/03/b6a197aa21ab92db93869fcbfa156b62.png"
width="300"
alt="field_name_and_value"
/>
- **字段Field Name**:字段名是对该元数据的简短描述,它表示该字段所代表的内容。例如"author""language"等
- **字段值Value**:字段值是该字段的具体信息或属性,例如"Jack""English"。
- **字段值计数Value Count**:字段值计数是指在某条元数据字段中标记的字段值数量,包括重复项。例如,此处的"3"是字段值计数,指该字段中有 3 个独特的字段值
<img
src="https://assets-docs.dify.ai/2025/03/b6a197aa21ab92db93869fcbfa156b62.png"
width="300"
className="mx-auto"
alt="metadata_field"
src="https://assets-docs.dify.ai/2025/03/330f26e90438cf50167c4cb6ce30e458.png"
width="300"
className="mx-auto"
alt="metadata_field"
/>
- **值类型Value Type**:值类型指字段值的类型。
- 目前Dify 的元数据功能支持以下三种值类型:
- **字符串**String文本值。
- **数字**Number数值。
- **时间**Time日期和时间。
- **值类型Value Type**:值类型指字段值的类型。
- 目前Dify 的元数据功能支持以下三种值类型:
- **字符串**String文本值。
- **数字**Number数值。
- **时间**Time日期和时间。
<img
src="https://assets-docs.dify.ai/2025/03/c208291ea8abae500819d195c2d52d65.png"
width="300"
className="mx-auto"
alt="metadata_field"
src="https://assets-docs.dify.ai/2025/03/f6adc7418869334805361535c8cd6874.png"
width="300"
alt="value_type"
/>
## 如何管理知识库元数据?
@@ -56,163 +52,72 @@ title: 元数据
#### 元数据管理界面简介
##### 入口
##### 进入元数据管理界面
在知识库管理界面,点击右上方的 **元数据** 按钮,进入元数据管理界面。
在知识库管理界面,点击右上方的 **元数据** 按钮,进入元数据管理界面。
![metadata_entrance](https://assets-docs.dify.ai/2025/03/bd43305d49cc1511683b4a098c8f6e5a.png)
![metadata_panel](https://assets-docs.dify.ai/2025/03/6000c85b5d2e29a2a5af5e0a047a7a59.png)
##### 功能
- **查看元数据字段**:你可以查看知识库的内置元数据和自定义元数据。​**内置元数据Built-in** 是系统自动生成的字段;**自定义元数据** 是用户根据需求手动添加的字段。
- **新增元数据字段**:通过点击 **添加元数据** 按钮,你可以添加新的元数据字段并选择字段值类型与填写字段名。
- **编辑元数据字段**:通过点击每条元数据字段旁的编辑图标,你可以修改字段的名称。
- **删除元数据字段**:通过点击每条元数据字段旁的删除图标,你可以移除不再需要的字段。
##### 价值
**元数据管理界面支持用户集中管理知识库中的元数据字段。​** 这一界面能帮助用户灵活地调整文档的标识属性,使得文档在检索和访问时更加高效、准确。
##### 知识库元数据字段的类型
在知识库中,元数据字段分为两类:**内置元数据Built-in** 和 **自定义元数据**。
在知识库中,元数据字段分为两类:**内置元数据Built-in** 和 **自定义元数据**。
<table>
<thead>
<tr>
<th>对比项</th>
<th>内置元数据BUILT-IN</th>
<th>自定义元数据</th>
</tr>
</thead>
<tbody>
<tr>
<td>显示位置</td>
<td>知识库界面 <strong>元数据</strong> 栏的下半部分。</td>
<td>知识库界面 <strong>元数据</strong> 栏的上半部分。</td>
</tr>
<tr>
<td>示例图</td>
<td align="center">
<img src="https://assets-docs.dify.ai/2025/03/5d03e958ed936badf4eb1ca955372c8b.png" alt="内置元数据示例" width="150" />
</td>
<td align="center">
<img src="https://assets-docs.dify.ai/2025/03/692a2824501f4e2f5fcc016e27159859.png" alt="自定义元数据示例" width="150" />
</td>
</tr>
<tr>
<td>启用方式</td>
<td>默认禁用,需要手动开启才能生效。</td>
<td>由用户根据需求自由添加。</td>
</tr>
<tr>
<td>生成方式</td>
<td>启用后,由系统自动提取相关信息并生成字段值。</td>
<td>用户手动添加,完全由用户自定义。</td>
</tr>
<tr>
<td>修改权限</td>
<td>一旦生成,无法修改字段与字段值。</td>
<td>可以删除或编辑字段名称,也可以修改字段值。</td>
</tr>
<tr>
<td>应用范围</td>
<td>启用后,适用于已上传和新上传的所有文档。</td>
<td>添加元数据字段后,字段会储存在知识库的元数据列表中/需要手动设置,才能将该字段应用于具体文档。</td>
</tr>
<tr>
<td>字段</td>
<td>
由系统预定义。包括:
<ul>
<li><strong>Original filename</strong>string原始文件名。</li>
<li><strong>Uploader</strong>string上传者。</li>
<li><strong>Upload date</strong>time上传日期。</li>
<li><strong>Last update date</strong>time最后更新时间。</li>
<li><strong>Source</strong>string文件来源。</li>
</ul>
</td>
<td>在初始状态下,知识库无自定义元数据字段,需要用户手动添加。</td>
</tr>
<tr>
<td>字段值类型</td>
<td>
用户可以自由选择字段值类型。目前Dify 的元数据功能仅支持以下三种值类型:
<ul>
<li><strong>字符串</strong>string文本值。</li>
<li><strong>数字</strong>number数值。</li>
<li><strong>时间</strong>time日期和时间。</li>
</ul>
</td>
<td>
用户可以自由选择字段值类型。目前Dify 的元数据功能仅支持以下三种值类型:
<ul>
<li><strong>字符串</strong>string文本值。</li>
<li><strong>数字</strong>number数值。</li>
<li><strong>时间</strong>time日期和时间。</li>
</ul>
</td>
</tr>
<tr>
<td>使用场景</td>
<td>适用于存储和展示文档的基本信息,如文件名、上传者、上传日期等。</td>
<td>适用于需要根据特定业务需求自定义的元数据字段,如文档的保密级别、标签等。</td>
</tr>
</tbody>
</table>
| | 内置元数据Built-in | 自定义元数据 |
| --- | --- | --- |
| 显示位置 | 知识库界面 元数据 栏的下半部分。 | 知识库界面 元数据 栏的上半部分。 |
| 启用方式 | 默认禁用,需要手动开启才能生效。 | 由用户根据需求自由添加。 |
| 生成方式 | 启用后,由系统自动提取相关信息并生成字段值。 | 用户手动添加,完全由用户自定义。 |
| 修改权限 | 一旦生成,无法修改字段与字段值。 | 可以删除或编辑字段名称,也可以修改字段值。 |
| 应用范围 | 启用后,适用于已上传和新上传的所有文档。 | 添加元数据字段后,字段会储存在知识库的元数据列表中/需要手动设置,才能将该字段应用于具体文档。 |
| 字段 | 由系统预定义,包括:• document_name (string):文件名• uploader (string):上传者• upload_date (time):上传日期• last_update_date (time):最后更新时间• source (string):文件来源 | 在初始状态下,知识库无自定义元数据字段,需要用户手动添加。 |
| 字段值类型 | • 字符串 (string):文本值• 数字 (number):数值• 时间 (time):日期和时间 | • 字符串 (string):文本值• 数字 (number):数值• 时间 (time):日期和时间 |
#### 新建元数据字段
1. 点击 **添加元数据** 按钮,弹出 **新建元数据** 弹窗。
1. 点击 **+添加元数据** 按钮,弹出 **新建元数据** 弹窗。
![new_metadata](https://assets-docs.dify.ai/2025/03/5086db42c40be64e54926b645c38c9a0.png)
2. 在 **字段值类型** 中选择元数据字段的值类型。
- **字符串**String文本值。
- **数字**Number数值。
- **时间**Time日期和时间。
2. 在 **字段值类型** 中选择元数据字段的值类型。
3. 在 **名称** 框中填写字段的名称。
3. 在 **名称** 框中填写字段的名称。
> 字段名仅支持小写字母、数字和下划线_字符不支持空格和大写字母。
<img
src="https://assets-docs.dify.ai/2025/03/24e85f14d4c7c3bcade25a7abfc15467.png"
width="300"
className="mx-auto"
alt="metadata_field"
src="https://assets-docs.dify.ai/2025/03/f6adc7418869334805361535c8cd6874.png"
width="300"
alt="value_type"
/>
4. 点击 **保存** 按钮,保存字段。
> 如果新建单条字段,该字段将在知识库的所有文档中同步更新。
4. 点击 **保存** 按钮,保存字段。
![save_field](https://assets-docs.dify.ai/2025/03/f44114cc58d4ba11ba60adb2d04c9b4c.png)
#### 修改元数据字段
1. 点击单条元数据字段右侧的编辑按钮,弹出 **重命名** 弹窗。
1. 点击单条元数据字段右侧的编辑按钮,弹出 **重命名** 弹窗。
![rename_field_1](https://assets-docs.dify.ai/2025/03/94327185cbe366bf99221abf2f5ef55a.png)
2. 在 **名称** 框中修改字段名称。
2. 在 **名称** 框中修改字段名称。
> 此弹窗仅支持修改字段名称,不支持修改字段值类型。
![](https://assets-docs.dify.ai/2025/03/216ec7d9227bb7b2a199c1bd5d3d812c.png)
<img
src="https://assets-docs.dify.ai/2025/03/022e42c170b40c35622b9b156c8cc159.png"
width="300"
className="mx-auto"
alt="metadata_field"
src="https://assets-docs.dify.ai/2025/03/2c84eeed42ccb052c8a2558f0d128853.png"
width="350"
alt="rename_field_2"
/>
3. 点击 **保存** 按钮,保存修改后的字段。
> 修改并保存后,该字段将在知识库中的所有相关文档中同步更新。
![same_renamed_field](https://assets-docs.dify.ai/2025/03/022e42c170b40c35622b9b156c8cc159.png)
#### 删除元数据字段
点击单条元数据字段右侧的删除按钮,可以删除该字段。
@@ -227,108 +132,125 @@ title: 元数据
你可以在知识库管理界面批量编辑文档的元数据信息。
##### 编辑元数据弹窗简介
###### 入口
##### 打开编辑元数据弹窗
1. 打开知识库管理界面,在文档列表左侧的白色方框中勾选你希望批量操作的文档。勾选后,页面下方会弹出操作选项。
![edit_metadata_entrance](https://assets-docs.dify.ai/2025/03/18b0c435604db6173acba41662474446.png)
2. 点击操作选项中的 **元数据**,弹出 **编辑元数据** 弹窗。
2. 点击操作选项中的 **元数据**,弹出 **编辑元数据** 弹窗。
![edit_metadata](https://assets-docs.dify.ai/2025/03/719f3c31498f23747fed7d7349fd64ba.png)
###### 功能
- **查看选中文档的元数据信息:​** 在弹窗的上半部分的 **已有元数据** 区和下半部分的 **新增元数据** 区,你会看到所有选中文档的元数据字段和此次操作新增的元数据字段。
<Info>
每个字段的左侧会显示该字段的编辑状态:
未编辑:字段左侧为空白,表示该字段未进行修改。
已编辑:字段左侧显示蓝色圆点,表示该字段已经被编辑。
重置:将光标悬停在蓝色圆点上时,圆点会变为 **重置** 按钮。点击后,该字段的内容会恢复到未编辑时的状态。
</Info>
- **删改字段值:​** 你可以在每条字段右侧的矩形框中删改其字段值。
<Info>
如果某个字段只有一个值,你会看到该字段的值直接显示在字段右侧的矩形框中,可以直接修改或删除。
如果某个字段有多个值,矩形框内会显示 **多个值** 卡片。如果删除该卡片,所有选中文档的该字段值将被清空,矩形框内会显示 **空** 标识。
</Info>
- **新增元数据字段:​** 如果你需要为选中的文档添加新的元数据字段,可以点击弹窗正下方的 **添加元数据** 按钮,在弹出的弹窗中 **新建字段、添加已创建的字段** 或 **管理已创建的字段**。
- **删除元数据字段:​** 通过点击每条元数据字段旁边的 **删除** 标识,你可以删除所有选中文档的该字段。
- **选择是否将操作应用于所有选中的文档:​** 通过界面底部的选框,你可以选择是否将编辑后的元数据内容应用于所有选中的文档。
##### 批量新增元数据信息
1. 在 **编辑元数据** 弹窗中点击底部的 **添加元数据** 按钮,弹出操作弹窗。
1. 在 **编辑元数据** 弹窗中点击底部的 **+添加元数据** 按钮,弹出操作弹窗。
![add_metadata](https://assets-docs.dify.ai/2025/03/868f51bbd6893e32bf23952c6d0aa079.png)
<img
src="https://assets-docs.dify.ai/2025/03/d4e4f87447c3e445d5b7507df1126c7b.png"
width="400"
alt="add_metadata"
/>
- 如需为选中文档新建字段,可以点击弹窗下方的 **新建元数据** 按钮,并参考前文的 **新建元数据字段** 章节新建字段。
> 在 **编辑元数据** 弹窗中新建的元数据字段,将自动同步至知识库字段列表中。
- 如需为选中文档添加已创建的字段:
![new_metadata_field](https://assets-docs.dify.ai/2025/03/e32211f56421f61b788943ba40c6959e.png)
- 可以从下拉列表中选择已有的字段,添加到字段列表中。
- 如需为选中文档添加已创建的字段:
- 可以在 **搜索元数据** 搜索框中搜索你需要的字段,添加到该文档的字段列表中。
<img
src="https://assets-docs.dify.ai/2025/03/ea9aab2c4071bf2ec75409b05725ac1f.png"
width="400"
alt="existing_field"
/>
- 可以从下拉列表中选择已有的字段,添加到字段列表中
- 如需为选中文档新建字段,可以点击弹窗左下角的 **+新建元数据** 按钮,并参考前文的 **新建元数据字段** 章节新建字段
> 在 **+新建元数据** 弹窗中新建的元数据字段,将自动同步至知识库字段列表中。
- 可以在 **搜索元数据** 搜索框中搜索你需要的字段,添加到该文档的字段列表中。
![existing_field](https://assets-docs.dify.ai/2025/03/ea9aab2c4071bf2ec75409b05725ac1f.png)
- 如需管理已创建的字段,可以点击该弹窗右下角的 **管理** 按钮,跳转到知识库的管理界面。
<img
src="https://assets-docs.dify.ai/2025/03/e32211f56421f61b788943ba40c6959e.png"
width="400"
alt="new_metadata_field"
/>
- 如需管理已创建的字段,可以点击该弹窗右下角的 **管理** 按钮,跳转到知识库的管理界面。
![manage_field](https://assets-docs.dify.ai/2025/03/82561edeb747b100c5295483c6238ffa.png)
<img
src="https://assets-docs.dify.ai/2025/03/82561edeb747b100c5295483c6238ffa.png"
width="400"
alt="manage_field"
/>
2. *(可选)* 新增字段后,在字段值框内填写该字段相应的字段值。
![value_for_field](https://assets-docs.dify.ai/2025/03/34c77cbf60fa524456aa8f3df8d7a576.png)
- 如果值类型为 **时间**,在填写字段值时会弹出时间选择器,供你选择具体时间。
<img
src="https://assets-docs.dify.ai/2025/03/aabfe789f607a1db9062beb493213376.png"
width="400"
alt="value_for_field"
/>
![date_picker](https://assets-docs.dify.ai/2025/03/8c991925c204703a4dceab42a23d684e.png)
- 如果值类型为 **时间**,在填写字段值时会弹出时间选择器,供你选择具体时间。
3. 点击 **保存** 按钮,保存操作。
<img
src="https://assets-docs.dify.ai/2025/03/65df828e605ebfb4947fccce189520a3.png"
width="440"
alt="date_picker"
/>
3. 点击 **保存** 按钮,保存操作。
##### 批量删改元数据信息
1. 在 **编辑元数据** 弹窗中删改元数据信息:
1. 在 **编辑元数据** 弹窗中删改元数据信息:
- **添加字段值** 在需要添加元数据值的字段框内直接输入所需值。
- **添加字段值** 在需要添加元数据值的字段框内直接输入所需值。
- **重置字段值** 将光标悬停在字段名左侧的蓝色圆点上,蓝点将变为 **重置** 按钮。点击蓝点,将字段框内修改后的内容重置为原始元数据值。
![reset_values](https://assets-docs.dify.ai/2025/03/01c0cde5a6eafa48e1c6e5438fc2fa6b.png)
- **重置字段值** 将光标悬停在字段名左侧的蓝色圆点上,蓝点将变为 **重置** 按钮。点击蓝点,将字段框内修改后的内容重置为原始元数据值。
- **删除字段值:​**
- 删除一个字段值:在需要删除字段值的字段框内直接删除该字段值。
<img
src="https://assets-docs.dify.ai/2025/03/01c0cde5a6eafa48e1c6e5438fc2fa6b.png"
width="400"
alt="reset_values"
/>
- 删除多个字段值:点击 **多个值** 卡片的删除图标,清空所有选中文档的该元数据字段的值。
- **删除字段值**
![multiple_values](https://assets-docs.dify.ai/2025/03/9cea5f8d4e2f1fb5bbd4812c875210f4.png)
- 删除一个字段值:在需要删除字段值的字段框内直接删除该字段值。
- **删除单条元数据字段:​** 点击字段最右侧的删除符号,删除该字段。删除后,该字段会被横线划掉且置灰
> 此操作仅会删除已选文档的该字段与字段值,字段本身依然保留在知识库中。
![delete_fields](https://assets-docs.dify.ai/2025/03/ed8c9143ba9a8eae6efcb76e309dbec1.png)
- 删除多个字段值:点击 **多个值** 卡片的删除图标,清空所有选中文档的该元数据字段的值
2. 点击 **保存** 按钮,保存操作。
<img
src="https://assets-docs.dify.ai/2025/03/5c4323095644d2658881b783246914f1.png"
width="400"
alt="multiple_values"
/>
- **删除单条元数据字段** 点击字段最右侧的删除符号,删除该字段。删除后,该字段会被横线划掉且置灰。
> 此操作仅会删除已选文档的该字段与字段值,字段本身依然保留在知识库中。
<img
src="https://assets-docs.dify.ai/2025/03/1b0318b898f951e307e3dc8cdc2f48d3.png"
width="400"
alt="delete_fields"
/>
2. 点击 **保存** 按钮,保存操作。
##### 调整批量操作的应用范围
你可以使用 **编辑元数据** 弹窗左下角的 **应用于所有文档** 选框来调整编辑模式中改动的应用范围。
- **调整批量操作的应用范围** 你可以使用 **编辑元数据** 弹窗左下角的 **应用于所有文档** 选框来调整编辑模式中改动的应用范围。
- **否(默认)** 如果不选中该选项,编辑模式中的改动仅对原本已有该元数据字段的文档生效,其他文档不会受到影响。
- **否(默认)** 如果不选中该选项,编辑模式中的改动仅对原本已有该元数据字段的文档生效,其他文档不会受到影响。
- **是** 如果选中该选项,编辑模式中的改动会对所有选中的文档生效。原本没有该字段的文档,会自动添加该字段。
- **是** 如果选中该选项,编辑模式中的改动会对所有选中的文档生效。原本没有该字段的文档,会自动添加该字段。
![apply_all_changes](https://assets-docs.dify.ai/2025/03/4f95cdd2daef1cdbc63f8e249da71f1c.png)
<img
src="https://assets-docs.dify.ai/2025/03/4550c68960802c24271492b63a39ad05.png"
width="400"
alt="apply_all_changes"
/>
#### 编辑单篇文档元数据信息
@@ -336,7 +258,7 @@ title: 元数据
##### 进入文档元数据编辑模式
1. 在文档详情界面,点击信息栏上方的 **开始标记** 按钮。
1. 在文档详情界面,点击信息栏上方的 **开始标记** 按钮。
![details_page](https://assets-docs.dify.ai/2025/03/066cb8eaa89f6ec17aacd8b09f06771c.png)
@@ -346,27 +268,26 @@ title: 元数据
##### 新增文档元数据信息
1. 在文档的元数据编辑模式中,点击 **添加元数据** 按钮,弹出操作弹窗。
1. 在文档的元数据编辑模式中,点击 **+添加元数据** 按钮,弹出操作弹窗。
![add_metadata](https://assets-docs.dify.ai/2025/03/f9ba9b10bbcf6eaca787eed4fcde44da.png)
- 如需使用新建字段为该文档标记字段值,可以点击弹窗左下角的 **新建元数据** 按钮,并参考前文的 **新建元数据字段** 章节新建字段。
- 如需使用新建字段为该文档标记字段值,可以点击弹窗左下角的 **+ 新建元数据** 按钮,并参考前文的 **新建元数据字段** 章节新建字段。
> 在文档页面新建的元数据字段,将自动同步至知识库字段列表中。
![new_fields](https://assets-docs.dify.ai/2025/03/739e7e51436259fca45d16065509fabb.png)
> 在文档页面新建的元数据字段,将自动同步至知识库字段列表中。
![new_fields](https://assets-docs.dify.ai/2025/03/739e7e51436259fca45d16065509fabb.png)
- 如需使用知识库已有的字段为该文档标记字段值,可以选择下列任意一种方式使用已有的字段:
- 如需使用知识库已有的字段为该文档标记字段值,可以选择下列任意一种方式使用已有的字段:
- 从下拉列表中选择知识库已有的字段,添加到该文档的字段列表中。
- 从下拉列表中选择知识库已有的字段,添加到该文档的字段列表中。
- 在 **搜索元数据** 搜索框中搜索你需要的字段,添加到该文档的字段列表中。
![existing_fields](https://assets-docs.dify.ai/2025/03/5b1876e8bc2c880b3b774c97eba371ab.png)
- 在 **搜索元数据** 搜索框中搜索你需要的字段,添加到该文档的字段列表中。
![existing_fields](https://assets-docs.dify.ai/2025/03/5b1876e8bc2c880b3b774c97eba371ab.png)
- 如需管理知识库已有的字段,可以点击弹窗右下角的 **管理** 按钮,跳转到知识库的管理界面。
![manage_metadata](https://assets-docs.dify.ai/2025/03/8dc74a1d2cdd87294e58dbc3d6dd161b.png)
- 如需管理知识库已有的字段,可以点击弹窗右下角的 **管理** 按钮,跳转到知识库的管理界面。
![manage_metadata](https://assets-docs.dify.ai/2025/03/8dc74a1d2cdd87294e58dbc3d6dd161b.png)
2. *(可选)* 添加字段后,在字段名右侧的元数据栏中填写字段值。
@@ -381,13 +302,13 @@ title: 元数据
![edit_mode](https://assets-docs.dify.ai/2025/03/bb33a0f9c6980300c0f979f8dc0d274d.png)
2. 删改文档元数据信息:
- **删改字段值** 在字段名右侧的字段值框内,删除或修改字段值。
- **删改字段值** 在字段名右侧的字段值框内,删除或修改字段值。
> 此模式仅支持修改字段值,不支持修改字段名。
> 此模式仅支持修改字段值,不支持修改字段名。
- **删除字段** 点击字段值框右侧的删除按钮,删除字段。
- **删除字段** 点击字段值框右侧的删除按钮,删除字段。
> 此操作仅会删除该文档的该字段与字段值,字段本身依然保留在知识库中。
> 此操作仅会删除该文档的该字段与字段值,字段本身依然保留在知识库中。
![edit_metadata](https://assets-docs.dify.ai/2025/03/4c0c4d83d3ad240568f316abfccc9c2c.png)
@@ -395,94 +316,35 @@ title: 元数据
## 如何使用元数据功能在知识库中筛选文档?
请参阅 [在应用内集成知识库](./integrate-knowledge-within-application) 中的 **使用元数据筛选知识** 章节。
请参阅 [在应用内集成知识库](https://docs.dify.ai/zh-hans/guides/knowledge-base/integrate-knowledge-within-application) 中的 **使用元数据筛选知识** 章节。
## API 信息
请参阅 [通过 API 维护知识库](./knowledge-and-documents-maintenance/maintain-dataset-via-api)。
请参阅 [通过 API 维护知识库](https://docs.dify.ai/zh-hans/guides/knowledge-base/knowledge-and-documents-maintenance/maintain-dataset-via-api)。
## FAQ
- **元数据有什么作用?**
- 提升搜索效率:用户可以根据元数据标签快速筛选和查找相关信息,节省时间并提高工作效率。
- 提升搜索效率:用户可以根据元数据标签快速筛选和查找相关信息,节省时间并提高工作效率。
- 增强数据安全性:通过元数据设置访问权限,确保只有授权用户能访问敏感信息,保障数据的安全性。
- 增强数据安全性:通过元数据设置访问权限,确保只有授权用户能访问敏感信息,保障数据的安全性。
- 优化数据管理能力:元数据帮助企业或组织有效分类和存储数据,提高数据的管理和检索能力,增强数据的可用性和一致性。
- 优化数据管理能力:元数据帮助企业或组织有效分类和存储数据,提高数据的管理和检索能力,增强数据的可用性和一致性。
- 支持自动化流程:元数据在文档管理、数据分析等场景中可以自动触发任务或操作,简化流程并提高整体效率。
- 支持自动化流程:元数据在文档管理、数据分析等场景中可以自动触发任务或操作,简化流程并提高整体效率。
- **知识库元数据管理列表中的元数据字段和某篇文档中的元数据值有什么区别?**
| | 定义 | 性质 | 举例 |
|---|---|---|---|
| / | 定义 | 性质 | 举例 |
| --- | --- | --- | --- |
| 元数据管理列表中的元数据字段 | 预定义的字段,用于描述文档的某些属性。 | 全局性字段。所有文档都可以使用这些字段。 | 作者、文档类型、上传日期。 |
| 某篇文档中的元数据值 | 每个文档按需标记的针对特定文档的信息。 | 文档特定的值。每个文档根据其内容会标记不同的元数据值。 | 文档 A 的"作者"字段值为"张三",文档 B 的"作者"字段值为"李四"。 |
- **在知识库管理界面删除某条元数据字段”“在编辑元数据弹窗中删除已选文档的某条元数据字段”和“在文档详情界面删除某条元数据字段有什么区别?**
- **"在知识库管理界面删除某条元数据字段""在编辑元数据弹窗中删除已选文档的某条元数据字段"和"在文档详情界面删除某条元数据字段"有什么区别?**
<table>
<thead>
<tr>
<th>操作方式</th>
<th>操作方法</th>
<th>示例图</th>
<th>影响范围</th>
<th>结果</th>
</tr>
</thead>
<tbody>
<tr>
<td>在知识库管理界面删除某条元数据字段</td>
<td>在知识库管理界面,点击某条元数据字段右侧的删除图标,删除该字段。</td>
<td align="center">
<img
src="https://assets-docs.dify.ai/2025/03/13367a865d589a29b7c4098526fad5dc.png"
alt="knowledge_base_delete"
width="150"
/>
</td>
<td>从知识库管理列表中完全删除该元数据字段及其所有字段值。</td>
<td>该字段从知识库中移除,所有文档中的该字段及包含的所有字段值也会消失。</td>
</tr>
<tr>
<td>在编辑元数据弹窗中删除已选文档的某条元数据字段</td>
<td>在编辑元数据弹窗中,点击某条元数据字段右侧的删除图标,删除该字段。</td>
<td align="center">
<img
src="https://assets-docs.dify.ai/2025/03/ed8c9143ba9a8eae6efcb76e309dbec1.png"
alt="bulk_delete"
width="150"
/>
</td>
<td>仅删除已选文档的该字段与字段值,字段本身依然保留在知识库管理列表中。</td>
<td>选中文档中的字段与字段值被移除,但字段仍保留在知识库内,字段值计数会发生数值上的变化。</td>
</tr>
<tr>
<td>在文档详情界面删除某条元数据字段</td>
<td>在文档详情界面中的元数据编辑模式里,点击某条元数据字段右侧的删除图标,删除该字段。</td>
<td align="center">
<img
src="https://assets-docs.dify.ai/2025/03/19d7fe886dd30a3f3322fa2a87f87203.png"
alt="single_delete"
width="150"
/>
</td>
<td>仅删除该文档的该字段与字段值,字段本身依然保留在知识库管理列表中。</td>
<td>该文档中的字段与字段值被移除,但字段仍保留在知识库内,字段值计数会发生数值上的变化。</td>
</tr>
</tbody>
</table>
- **我可以在知识库管理界面查看我设置的元数据值吗?**
目前在知识库管理界面你只能看到每条元数据字段的字段值计数如“3 values”无法查看字段值的具体内容。
如果你需要查看字段值的具体内容,可以在单个文档的详情界面中查看。
- **我可以在编辑元数据弹窗中删除单个元数据值吗?**
在 **编辑元数据弹窗** 中,你只能删除 **多个值** 卡片。删除该卡片将清空所有选中文档的该元数据字段的值。
如果你想删除单个元数据值,你需要进入对应文档的详情界面,并参照前文的 **编辑单篇文档的元数据值 > 删改文档元数据信息值** 章节进行操作。
| 操作方式 | 操作方法 | 示例图 | 影响范围 | 结果 |
| --- | --- | --- | --- | --- |
| 在知识库管理界面删除某条元数据字段 | 在知识库管理界面,点击某条元数据字段右侧的删除图标,删除该字段。 | ![knowledge_base_delete](https://assets-docs.dify.ai/2025/03/13367a865d589a29b7c4098526fad5dc.png) | 从知识库管理列表中完全删除该元数据字段及其所有字段值。 | 该字段从知识库中移除,所有文档中的该字段及包含的所有字段值也会消失。 |
| 在编辑元数据弹窗中删除已选文档的某条元数据字段 | 在编辑元数据弹窗中,点击某条元数据字段右侧的删除图标,删除该字段。 | ![bulk_delete](https://assets-docs.dify.ai/2025/03/ed8c9143ba9a8eae6efcb76e309dbec1.png) | 仅删除已选文档的该字段与字段值,字段本身依然保留在知识库管理列表中。 | 选中文档中的字段与字段值被移除,但字段仍保留在知识库内,字段值计数会发生数值上的变化。 |
| 在文档详情界面删除某条元数据字段 | 在文档详情界面中的元数据编辑模式里,点击某条元数据字段右侧的删除图标,删除该字段。 | ![single_delete](https://assets-docs.dify.ai/2025/03/19d7fe886dd30a3f3322fa2a87f87203.png) | 仅删除该文档的该字段与字段值,字段本身依然保留在知识库管理列表中。 | 该文档中的字段与字段值被移除,但字段仍保留在知识库内,字段值计数会发生数值上的变化。 |