Parent chunk api bug. #12704

Closed
opened 2026-02-21 19:08:39 -05:00 by yindo · 2 comments
Owner

Originally created by @HojaMuerta on GitHub (Apr 9, 2025).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.2.0

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

I use knowledge parent api to update doc.
post body:
{ "request": "POST /v1/datasets/xxxxxx/document/create-by-text HTTP/1.1\r\nHost: xx.xx.xx.xx\r\nAuthorization: Bearer dataset-xxxxxx\r\nContent-Type: application/json\r\nContent-Length: 6780\r\n\r\n{\"name\": \"xxx", \"text\": \"xxx", \"doc_form\": \"hierarchical_model\", \"indexing_technique\": \"high_quality\", \"process_rule\": {\"mode\": \"custom\", \"rules\": {\"pre_processing_rules\": [{\"id\": \"remove_extra_spaces\", \"enabled\": true}, {\"id\": \"remove_urls_emails\", \"enabled\": true}], \"segmentation\": {\"separator\": \"#\", \"max_tokens\": 1000, \"chunk_overlap\": 150}, \"parent_mode\": \"full-doc\", \"subchunk_segmentation\": {\"separator\": \"#\", \"max_tokens\": 999, \"chunk_overlap\": 150}}}}" }
But I got this:
The content is only one child chunk.
Image

The correct expected effect is shown in the following picture, which is the result after manually segmenting the first picture.

Image

✔️ Expected Behavior

Image

Actual Behavior

Image

Originally created by @HojaMuerta on GitHub (Apr 9, 2025). ### Self Checks - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.2.0 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce I use knowledge parent api to update doc. post body: `{ "request": "POST /v1/datasets/xxxxxx/document/create-by-text HTTP/1.1\r\nHost: xx.xx.xx.xx\r\nAuthorization: Bearer dataset-xxxxxx\r\nContent-Type: application/json\r\nContent-Length: 6780\r\n\r\n{\"name\": \"xxx", \"text\": \"xxx", \"doc_form\": \"hierarchical_model\", \"indexing_technique\": \"high_quality\", \"process_rule\": {\"mode\": \"custom\", \"rules\": {\"pre_processing_rules\": [{\"id\": \"remove_extra_spaces\", \"enabled\": true}, {\"id\": \"remove_urls_emails\", \"enabled\": true}], \"segmentation\": {\"separator\": \"#\", \"max_tokens\": 1000, \"chunk_overlap\": 150}, \"parent_mode\": \"full-doc\", \"subchunk_segmentation\": {\"separator\": \"#\", \"max_tokens\": 999, \"chunk_overlap\": 150}}}}" }` But I got this: The content is only one child chunk. ![Image](https://github.com/user-attachments/assets/a7f1dc74-107d-474c-a66a-1726c9926a8e) The correct expected effect is shown in the following picture, which is the result after manually segmenting the first picture. ![Image](https://github.com/user-attachments/assets/0b471e3c-be88-4881-bad9-7c04bf259314) ### ✔️ Expected Behavior ![Image](https://github.com/user-attachments/assets/ca7338e4-bd5e-4ed5-917c-92ca0f73befa) ### ❌ Actual Behavior ![Image](https://github.com/user-attachments/assets/27b81426-f292-456d-8501-fec8585b0869)
yindo added the 🐞 bug label 2026-02-21 19:08:39 -05:00
yindo closed this issue 2026-02-21 19:08:39 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Apr 9, 2025):

The issue you're experiencing with the Knowledge Parent API returning only one child chunk instead of multiple subsections could be related to the configuration of your process_rule parameter. Here are a few things to check and consider:

  1. Segmentation Rules: Ensure that the segmentation and subchunk_segmentation rules are correctly defined. The separator and max_tokens settings should be appropriate for your document's structure. The chunk_overlap parameter should also be set correctly to allow for the desired overlap between chunks.

  2. Parent Mode: Since you are using parent_mode set to full-doc, the system might be treating the entire document as a single parent chunk. This setting influences whether child chunks are retrieved or not. If parent_mode is set to full-doc, it might not create multiple child chunks as expected [1].

  3. Process Rule Structure: Verify that the JSON structure of your process_rule is correct. The parent_mode and subchunk_segmentation should be placed under the rules object, not directly under process_rule. Incorrect placement can lead to segmentation issues [2].

  4. Dify Version: Ensure that you are using a version of Dify that includes any necessary bug fixes related to segmentation. You mentioned using version 1.2.0, so check if there are any updates or patches available that address this issue.

By reviewing these aspects, you should be able to identify and resolve the issue with the document segmentation. If the problem persists, consider testing with different segmentation settings to see if the behavior changes.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@dosubot[bot] commented on GitHub (Apr 9, 2025): <!-- Answer --> The issue you're experiencing with the Knowledge Parent API returning only one child chunk instead of multiple subsections could be related to the configuration of your `process_rule` parameter. Here are a few things to check and consider: 1. **Segmentation Rules**: Ensure that the `segmentation` and `subchunk_segmentation` rules are correctly defined. The `separator` and `max_tokens` settings should be appropriate for your document's structure. The `chunk_overlap` parameter should also be set correctly to allow for the desired overlap between chunks. 2. **Parent Mode**: Since you are using `parent_mode` set to `full-doc`, the system might be treating the entire document as a single parent chunk. This setting influences whether child chunks are retrieved or not. If `parent_mode` is set to `full-doc`, it might not create multiple child chunks as expected <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/models/dataset.py)</sup>. 3. **Process Rule Structure**: Verify that the JSON structure of your `process_rule` is correct. The `parent_mode` and `subchunk_segmentation` should be placed under the `rules` object, not directly under `process_rule`. Incorrect placement can lead to segmentation issues <sup>[[2]](https://github.com/langgenius/dify/issues/13013)</sup>. 4. **Dify Version**: Ensure that you are using a version of Dify that includes any necessary bug fixes related to segmentation. You mentioned using version 1.2.0, so check if there are any updates or patches available that address this issue. By reviewing these aspects, you should be able to identify and resolve the issue with the document segmentation. If the problem persists, consider testing with different segmentation settings to see if the behavior changes. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/c0a2a175-b95b-45af-8e39-0f28a35f5dce?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/c0a2a175-b95b-45af-8e39-0f28a35f5dce?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/c0a2a175-b95b-45af-8e39-0f28a35f5dce?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/c0a2a175-b95b-45af-8e39-0f28a35f5dce?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/c0a2a175-b95b-45af-8e39-0f28a35f5dce?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/c0a2a175-b95b-45af-8e39-0f28a35f5dce?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/c0a2a175-b95b-45af-8e39-0f28a35f5dce?feedback_type=other)</sup>
Author
Owner

@HojaMuerta commented on GitHub (Apr 9, 2025):

The knowledge api doc is wrong, when u use parent-child mode, the "mode" is supposed to be set as "hierarchical" rather than costum.

@HojaMuerta commented on GitHub (Apr 9, 2025): The knowledge api doc is wrong, when u use parent-child mode, the "mode" is supposed to be set as "hierarchical" rather than costum.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#12704