# 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