Skip to content

Commit

Permalink
refactor(core): update consts to better match corresponding env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
robinpyon committed Jul 17, 2023
1 parent eff4472 commit 9f97fd4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ interface IntermediateSearchType extends Omit<ExperimentalSearchPath, 'path'> {
export const DEFAULT_LIMIT = 1000

// Maximum number of unique searchable attributes to include in a single search query (across all document types)
const MAX_UNIQUE_ATTRIBUTES =
const SEARCH_ATTR_LIMIT =
// eslint-disable-next-line no-process-env
Number(process.env.SANITY_STUDIO_UNSTABLE_SEARCH_ATTR_LIMIT) || 1000

Expand Down Expand Up @@ -213,7 +213,7 @@ export function createSearchQuery(
* These optimized specs are used when building constraints in this search query and assigning
* weight to search hits.
*/
const optimizedSpecs = createSearchSpecs(searchTerms.types, true, MAX_UNIQUE_ATTRIBUTES).specs
const optimizedSpecs = createSearchSpecs(searchTerms.types, true, SEARCH_ATTR_LIMIT).specs

// Construct search filters used in this GROQ query
const filters = [
Expand Down
6 changes: 3 additions & 3 deletions packages/@sanity/schema/src/legacy/searchConfig/resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ export const pathCountSymbol = Symbol('__cachedPathCount')

// Max number of levels to traverse per root-level object
// eslint-disable-next-line no-process-env
const MAX_TRAVERSAL_DEPTH = Number(process.env.SANITY_STUDIO_UNSTABLE_SEARCH_DEPTH) || 15
const SEARCH_DEPTH_LIMIT = Number(process.env.SANITY_STUDIO_UNSTABLE_SEARCH_DEPTH_LIMIT) || 15

// Max number of search paths to extract per root-level object
// eslint-disable-next-line no-process-env
const MAX_OBJECT_SEARCH_PATHS = Number(process.env.SANITY_STUDIO_UNSTABLE_SEARCH_PATH_LIMIT) || 500
const SEARCH_PATH_LIMIT = Number(process.env.SANITY_STUDIO_UNSTABLE_SEARCH_PATH_LIMIT) || 500

const BASE_WEIGHTS = [
{weight: 1, path: ['_id']},
Expand Down Expand Up @@ -187,5 +187,5 @@ export function resolveSearchConfigForBaseFieldPaths(type: ObjectSchemaType): Se
}

export default function resolveSearchConfig(type: ObjectSchemaType): SearchPath[] {
return getCachedStringFieldPaths(type, MAX_TRAVERSAL_DEPTH, MAX_OBJECT_SEARCH_PATHS)
return getCachedStringFieldPaths(type, SEARCH_DEPTH_LIMIT, SEARCH_PATH_LIMIT)
}

0 comments on commit 9f97fd4

Please sign in to comment.