Problem
When the indexer aggregates file paths for identical content (see elastic/semantic-code-search-indexer#121), the MCP server needs to display this information properly to users.
Currently, search results show a single filePath. After the indexer change, documents will have:
filePaths: array of { path, startLine, endLine } objects
fileCount: total number of files containing this content
Proposed Changes
Update search result format:
Before:
{
"score": 0.92,
"content": "useContext(JobCreatorContext)",
"filePath": "ml/pick_fields_step/rare_field/rare_field.tsx",
"startLine": 18,
"endLine": 18
}
After:
{
"score": 0.92,
"content": "useContext(JobCreatorContext)",
"fileCount": 77,
"filePaths": [
"ml/pick_fields_step/categorization_view/top_categories.tsx:23",
"ml/pick_fields_step/influencers/influencers.tsx:31",
"ml/pick_fields_step/rare_field/rare_field.tsx:18",
"... and 74 more"
]
}
Implementation:
- Update
semantic_code_search.ts result mapping to include filePaths and fileCount
- Format
filePaths as path:startLine strings for readability
- Truncate to first 10 paths if
fileCount > 10, append "... and N more"
- Backward compatibility: handle documents with old
filePath field (single string) during migration period
Related
Acceptance Criteria
Problem
When the indexer aggregates file paths for identical content (see elastic/semantic-code-search-indexer#121), the MCP server needs to display this information properly to users.
Currently, search results show a single
filePath. After the indexer change, documents will have:filePaths: array of{ path, startLine, endLine }objectsfileCount: total number of files containing this contentProposed Changes
Update search result format:
Before:
{ "score": 0.92, "content": "useContext(JobCreatorContext)", "filePath": "ml/pick_fields_step/rare_field/rare_field.tsx", "startLine": 18, "endLine": 18 }After:
{ "score": 0.92, "content": "useContext(JobCreatorContext)", "fileCount": 77, "filePaths": [ "ml/pick_fields_step/categorization_view/top_categories.tsx:23", "ml/pick_fields_step/influencers/influencers.tsx:31", "ml/pick_fields_step/rare_field/rare_field.tsx:18", "... and 74 more" ] }Implementation:
semantic_code_search.tsresult mapping to includefilePathsandfileCountfilePathsaspath:startLinestrings for readabilityfileCount > 10, append "... and N more"filePathfield (single string) during migration periodRelated
Acceptance Criteria
filePathsarray andfileCountpath:linefor readabilityfilePathdocuments during migration