Skip to content

Commit 08c9f98

Browse files
RoyLinRoyLin
authored andcommitted
feat(search): include chunk context (heading/keywords) in search lines
Teach agentic_search to consume chunk context more directly: - Add [section] context_label lines for heading inheritance - Add [keywords] lines with extracted keywords This helps search ranking by including section context and keywords in the indexed content.
1 parent d22b380 commit 08c9f98

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

core/src/document/consume_search.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,26 @@ pub(crate) fn build_search_line_entries_from_chunks(
9696
}
9797
}
9898

99+
// Include heading context (context_label) for better search ranking
100+
if let Some(context) = &chunk.context_label {
101+
let context = context.trim();
102+
if !context.is_empty() {
103+
lines.push(SearchLineEntry {
104+
content: format!("[section] {}", context),
105+
locator: chunk.locator.clone(),
106+
});
107+
}
108+
}
109+
110+
// Include keywords for better search ranking
111+
if !chunk.keywords.is_empty() {
112+
let keywords = chunk.keywords.join(", ");
113+
lines.push(SearchLineEntry {
114+
content: format!("[keywords] {}", keywords),
115+
locator: chunk.locator.clone(),
116+
});
117+
}
118+
99119
for line in chunk.content.lines() {
100120
let line = line.trim_end();
101121
if !line.is_empty() {

0 commit comments

Comments
 (0)