SCHEMA-MIGRATION-REQUIRED.mdā¢6.51 kB
# CRITICAL: Schema Migration Required - Search API Changed
**Date**: October 16, 2025
**Status**: šØ BREAKING CHANGES FOUND
**Priority**: HIGH
---
## šØ Problem Summary
The `/items/master` schema has **COMPLETELY DIFFERENT** search API than `/edge`. The current code uses old `/edge` syntax which doesn't work.
### Current Issues
1. ā `executeQuery()` - Uses old `where: { name, value, operator }` syntax (BROKEN)
2. ā `searchItems()` - Same old syntax (BROKEN)
3. ā
`getChildren()` - Fixed in v1.2.1 (WORKING)
4. ā
`getItem()`, `getFieldValue()`, `getTemplate()` - Never used search (WORKING)
---
## š Schema Test Results
Ran `test-schema-validation.ps1`:
### ā
PASSING (7/8):
1. ā
`item()` ā Direct Item object
2. ā
`item().children()` ā Direct [Item] array
3. ā
`item().field()` ā Direct string
4. ā
`item().fields()` ā [ItemField] array
5. ā
`item().template` ā Direct Template object
6. ā
Endpoint `/items/master` ā Correct
7. ā
`children(first: N)` ā Pagination works
### ā FAILING (1/8):
8. ā `search()` ā Uses wrong syntax
---
## š Correct /items/master Search Schema
### Search Arguments
```graphql
search(
first: Int # Limit results
after: String # Cursor (default: "0")
rootItem: String # Path/ID to search under
keyword: String # Keyword search
fieldsEqual: [ItemSearchFieldQuery] # Field equality
fieldsContain: [ItemSearchFieldQuery] # Field contains
language: String # Language filter
# Many more filters...
)
```
### Return Type Structure
```graphql
type ContentSearchResults {
results: ContentSearchResultConnection! # Main results
facets: [FacetResult] # Search facets
totalCount: Int! # Total matches
}
type ContentSearchResultConnection {
items: [SearchResultItem]! # ā ļø Items array (not direct!)
pageInfo: PageInfo # Pagination info
}
type SearchResultItem {
item: Item! # ā ļø Wrapped in 'item'!
}
```
### Correct Query Example
```graphql
query {
search(
keyword: "home"
rootItem: "/sitecore/content"
first: 10
) {
results {
items { # ā ļø Access via .items
item { # ā ļø Then via .item
id
name
path
}
}
}
totalCount
}
}
```
### Access Pattern
```typescript
// ā OLD (doesn't work):
const items = result.search.results;
// ā
NEW (correct):
const items = result.search.results.items.map(i => i.item);
```
---
## š ļø Required Code Changes
### Priority 1: Disable Broken Tools
Until search is fixed, these tools will return errors:
- `sitecore_query` (uses executeQuery)
- `sitecore_search` (uses searchItems)
**Recommendation**: Add try/catch with clear error message:
```typescript
throw new Error(
"Search API migration in progress. " +
"This tool currently doesn't work with /items/master schema. " +
"Use sitecore_get_item or sitecore_get_children instead."
);
```
### Priority 2: Fix Search Methods
#### File: `src/sitecore-service.ts`
**Method 1: `executeQuery()` (line ~200)**
```typescript
// Current (BROKEN):
search(
where: { name: "_path", value: $path, operator: CONTAINS }
first: $first
language: $language
) {
results { id name } // ā Wrong structure
}
// Should be:
search(
rootItem: $path
first: $first
language: $language
) {
results {
items { // ā
Correct structure
item {
id
name
displayName
path
template { id name }
}
}
}
totalCount
}
```
**Method 2: `searchItems()` (line ~270)**
```typescript
// Current (BROKEN):
search(
where: { name: "_name", value: $searchText, operator: CONTAINS }
first: $first
) {
results { id name } // ā Wrong structure
}
// Should be:
search(
keyword: $searchText
rootItem: $rootPath
first: $first
) {
results {
items { // ā
Correct structure
item {
id
name
path
}
}
}
totalCount
}
```
---
## ā ļø Impact Assessment
### Tools Currently Broken
1. ā `sitecore_query` - Query execution (uses search)
2. ā `sitecore_search` - Search items (uses search)
3. ā `sitecore_command` - Natural language "search" commands
### Tools Still Working
1. ā
`sitecore_get_item` - Get single item
2. ā
`sitecore_get_children` - Get children (fixed v1.2.1)
3. ā
`sitecore_get_field_value` - Get field value
4. ā
`sitecore_get_template` - Get template info
5. ā
`sitecore_scan_schema` - Schema scanning (if introspection works)
### User Impact
- **Low**: Most common operations (get item, children, fields) still work
- **Medium**: Search functionality is broken
- **Workaround**: Use `get_children` recursively or manually
---
## š Action Items
### Immediate (This Session)
- [x] Document schema differences
- [x] Create SCHEMA-REFERENCE.md with correct patterns
- [x] Update copilot-instructions.md
- [x] Remove all /edge references
- [ ] Add error messages to broken search tools
- [ ] Update documentation (README, etc.)
### Next Session
- [ ] Rewrite `executeQuery()` with new search syntax
- [ ] Rewrite `searchItems()` with new search syntax
- [ ] Test all search scenarios
- [ ] Update natural language parser for search commands
- [ ] Full regression testing
### Future
- [ ] Add advanced search filters (fieldsEqual, fieldsContain)
- [ ] Add facet support
- [ ] Add search result highlighting
- [ ] Performance optimization
---
## šÆ Workarounds for Users
Until search is fixed:
### Instead of Search:
```typescript
// ā Broken:
/sitecore search articles
// ā
Use:
/sitecore get children /sitecore/content
// Then manually filter results
```
### Instead of Query:
```typescript
// ā Broken:
/sitecore query /sitecore/content//*[@@templatename='Article']
// ā
Use:
/sitecore get children /sitecore/content
// Then check template names manually
```
---
## š References
- **SCHEMA-REFERENCE.md** - Complete schema documentation
- **SCHEMA-FIX-CHILDREN.md** - Children fix (v1.2.1)
- **test-schema-validation.ps1** - Schema validation tests
- **graphql-schema-full.json** - Full schema JSON (217 MB)
---
**Status**: Documentation complete, code fixes pending
**Version**: 1.2.1 (search broken), next 1.3.0 (search fixed)
**Priority**: HIGH - Search is core functionality