|
1 | 1 | import {type SanityClient} from '@sanity/client'
|
| 2 | +import {DEFAULT_MAX_FIELD_DEPTH} from '@sanity/schema/_internal' |
2 | 3 | import {type ReferenceFilterSearchOptions, type ReferenceSchemaType} from '@sanity/types'
|
3 | 4 | import {combineLatest, type Observable, of} from 'rxjs'
|
4 | 5 | import {map, mergeMap, startWith, switchMap} from 'rxjs/operators'
|
5 | 6 |
|
6 | 7 | import {type DocumentPreviewStore, getPreviewPaths, prepareForPreview} from '../../../../preview'
|
7 |
| -import {createSearch, getSearchTypesWithMaxDepth} from '../../../../search' |
| 8 | +import {createSearch} from '../../../../search' |
8 | 9 | import {collate, type CollatedHit, getDraftId, getIdPair, isRecord} from '../../../../util'
|
9 | 10 | import {type ReferenceInfo, type ReferenceSearchHit} from '../../../inputs/ReferenceInput/types'
|
10 | 11 |
|
@@ -193,9 +194,10 @@ export function referenceSearch(
|
193 | 194 | options: ReferenceFilterSearchOptions,
|
194 | 195 | unstable_enableNewSearch: boolean,
|
195 | 196 | ): Observable<ReferenceSearchHit[]> {
|
196 |
| - const search = createSearch(getSearchTypesWithMaxDepth(type.to, options.maxFieldDepth), client, { |
| 197 | + const search = createSearch(type.to, client, { |
197 | 198 | ...options,
|
198 | 199 | unstable_enableNewSearch,
|
| 200 | + maxDepth: options.maxFieldDepth || DEFAULT_MAX_FIELD_DEPTH, |
199 | 201 | })
|
200 | 202 | return search(textTerm, {includeDrafts: true}).pipe(
|
201 | 203 | map(({hits}) => hits.map(({hit}) => hit)),
|
|
0 commit comments