Skip to content

fix(go-skill): Elasticsearch skill search field mapping - #16611

Merged
yuzhichang merged 1 commit into
infiniflow:mainfrom
Harry-Hz-Zhang:fix/skill-search
Jul 6, 2026
Merged

yuzhichang merged 1 commit into
infiniflow:mainfrom
Harry-Hz-Zhang:fix/skill-search

Conversation

@Harry-Hz-Zhang

Copy link
Copy Markdown
Contributor

Summary

Fix Elasticsearch-backed skill search by mapping skill search fields to their indexed token fields.

name, tags, description, and content are stored for display but are not searchable in the skill ES mapping. Search queries now target name_tks, tags_tks, description_tks, and content_tks.

Testing

  • Ran Go unit tests:
/usr/local/go/bin/go test -count=1 ./internal/engine/elasticsearch
  • Frontend verification:
    1. Open /files/skills.
    2. Enter a skill space.
    3. Reindex the skill space if existing skills were created before this fix.
    4. Search by skill name or description keyword.
    5. Confirm matching skills are returned.

@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jul 3, 2026
@coderabbitai

coderabbitai Bot commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 747225be-cef4-4d74-aeaf-0357ab252717

📥 Commits

Reviewing files that changed from the base of the PR and between 3cba34d and 2517a3d.

📒 Files selected for processing (2)
  • internal/engine/elasticsearch/chunk.go
  • internal/engine/elasticsearch/chunk_helpers_test.go

📝 Walkthrough

Walkthrough

This change adds skill-index field mapping to Elasticsearch query construction. A new helper, mapSkillSearchFields, converts document field names (name, tags, description, content) to their tokenized *_tks equivalents while preserving boost weights, applied conditionally in buildQueryStringQuery. New tests verify both mapped and unmapped behavior.

Changes

Skill Query Field Mapping

Layer / File(s) Summary
Field mapping helper and wiring
internal/engine/elasticsearch/chunk.go
Adds mapSkillSearchFields to convert skill field names to *_tks tokenized fields preserving ^<weight> boosts, invoked in buildQueryStringQuery when isSkillIndex is true.
Tests for field mapping behavior
internal/engine/elasticsearch/chunk_helpers_test.go
New tests verify mapped fields get _tks suffix with preserved boosts when enabled, and remain unchanged when mapping is disabled.

Estimated code review effort: 2 (Simple) | ~10 minutes

Poem

A hop, a skip, a field renamed,
"_tks" now proudly claimed,
Boosts preserved with careful care,
Tests confirm it's all squared,
This rabbit thumps in query glee! 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and clearly describes the Elasticsearch skill search field-mapping fix.
Description check ✅ Passed The description includes the required Summary section and adds useful testing notes, so it meets the template.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Harry-Hz-Zhang Harry-Hz-Zhang added 🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration labels Jul 3, 2026
@yuzhichang

Copy link
Copy Markdown
Member

LGTM

@yuzhichang
yuzhichang merged commit e5d2179 into infiniflow:main Jul 6, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants