MCPcopy Index your code
hub / github.com/PatrickSys/codebase-context / search

Method search

src/core/search.ts:916–1019  ·  view source on GitHub ↗
(
    query: string,
    limit: number = 5,
    filters?: SearchFilters,
    options: SearchOptions = DEFAULT_SEARCH_OPTIONS
  )

Source from the content-addressed store, hash-verified

914 }
915
916 async search(
917 query: string,
918 limit: number = 5,
919 filters?: SearchFilters,
920 options: SearchOptions = DEFAULT_SEARCH_OPTIONS
921 ): Promise<SearchResult[]> {
922 if (!this.initialized) {
923 await this.initialize();
924 }
925
926 const merged = {
927 ...DEFAULT_SEARCH_OPTIONS,
928 ...options
929 };
930 const {
931 useSemanticSearch,
932 useKeywordSearch,
933 profile,
934 enableQueryExpansion,
935 enableLowConfidenceRescue,
936 candidateFloor,
937 enableReranker
938 } = merged;
939
940 const { intent, weights: intentWeights } = this.classifyQueryIntent(query);
941 // Intent weights are the default; caller-supplied weights override them
942 const finalSemanticWeight = merged.semanticWeight ?? intentWeights.semantic;
943 const finalKeywordWeight = merged.keywordWeight ?? intentWeights.keyword;
944
945 const candidateLimit = Math.max(limit * 2, candidateFloor || 30);
946 const primaryVariants = this.buildQueryVariants(query, enableQueryExpansion ? 1 : 0);
947
948 const primaryMatches = await this.collectHybridMatches(
949 primaryVariants,
950 candidateLimit,
951 filters,
952 Boolean(useSemanticSearch),
953 Boolean(useKeywordSearch),
954 finalSemanticWeight,
955 finalKeywordWeight
956 );
957
958 const primaryTotalWeight =
959 primaryVariants.reduce((sum, v) => sum + v.weight, 0) *
960 (finalSemanticWeight + finalKeywordWeight);
961 const primaryResults = this.scoreAndSortResults(
962 query,
963 limit,
964 primaryMatches,
965 (profile || 'explore') as SearchIntentProfile,
966 intent,
967 primaryTotalWeight
968 );
969
970 let bestResults = primaryResults;
971
972 if (enableLowConfidenceRescue) {
973 const primaryQuality = assessSearchQuality(query, primaryResults);

Callers 1

handleFunction · 0.95

Calls 8

initializeMethod · 0.95
classifyQueryIntentMethod · 0.95
buildQueryVariantsMethod · 0.95
collectHybridMatchesMethod · 0.95
scoreAndSortResultsMethod · 0.95
pickBetterResultSetMethod · 0.95
assessSearchQualityFunction · 0.85
rerankFunction · 0.85

Tested by

no test coverage detected