Skip to content

Commit f2fc65b

Browse files
authored
Merge pull request #42604 from github/repo-sync
Repo sync
2 parents deb673d + 8092035 commit f2fc65b

File tree

10 files changed

+492
-340
lines changed

10 files changed

+492
-340
lines changed

package-lock.json

Lines changed: 456 additions & 297 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@
155155
]
156156
},
157157
"dependencies": {
158-
"@elastic/elasticsearch": "8.13.1",
158+
"@elastic/elasticsearch": "8.19.1",
159159
"@github/failbot": "0.8.3",
160160
"@gr2m/gray-matter": "4.0.3-with-pr-137",
161161
"@horizon-rs/language-guesser": "0.1.1",
@@ -217,7 +217,7 @@
217217
"mdast-util-to-hast": "^13.2.1",
218218
"mdast-util-to-markdown": "2.1.2",
219219
"mdast-util-to-string": "^4.0.0",
220-
"next": "^16.0.10",
220+
"next": "^16.1.5",
221221
"ora": "^9.0.0",
222222
"parse5": "7.1.2",
223223
"quick-lru": "7.0.1",
@@ -252,7 +252,7 @@
252252
},
253253
"devDependencies": {
254254
"@actions/core": "^2.0.0",
255-
"@actions/github": "^7.0.0",
255+
"@actions/github": "^8.0.1",
256256
"@axe-core/playwright": "^4.10.1",
257257
"@eslint/js": "^9.33.0",
258258
"@github/markdownlint-github": "^0.6.3",

src/search/components/results/SearchResults.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ import styles from './SearchResults.module.scss'
1313

1414
import type { SearchQueryContentT } from '@/search/components/types'
1515
import type { GeneralSearchHitWithoutIncludes, GeneralSearchResponse } from '@/search/types'
16-
import type { SearchTotalHits } from '@elastic/elasticsearch/lib/api/types'
16+
import type { estypes } from '@elastic/elasticsearch'
1717
import { GENERAL_SEARCH_RESULTS } from '@/events/components/event-groups'
1818

1919
type Props = {
2020
results: GeneralSearchResponse
2121
searchParams: SearchQueryContentT
2222
}
2323
export function SearchResults({ results, searchParams }: Props) {
24-
const pages = Math.ceil((results.meta.found as SearchTotalHits).value / results.meta.size)
24+
const pages = Math.ceil((results.meta.found as estypes.SearchTotalHits).value / results.meta.size)
2525
const { page } = results.meta
2626
const searchEventGroupId = useRef<string>('')
2727
useEffect(() => {

src/search/components/results/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { NoQuery } from '@/search/components/results/NoQuery'
99
import { useMainContext } from '@/frame/components/context/MainContext'
1010
import { ValidationErrors } from '@/search/components/results/ValidationErrors'
1111
import { useSearchContext } from '@/search/components/context/SearchContext'
12-
import type { SearchTotalHits } from '@elastic/elasticsearch/lib/api/types'
12+
import type { estypes } from '@elastic/elasticsearch'
1313

1414
export function Search() {
1515
const { search } = useSearchContext()
@@ -38,7 +38,7 @@ export function Search() {
3838
pageTitle += ` (${searchVersion})`
3939
}
4040
if (results) {
41-
pageTitle = `${formatInteger((results.meta.found as SearchTotalHits).value)} ${pageTitle}`
41+
pageTitle = `${formatInteger((results.meta.found as estypes.SearchTotalHits).value)} ${pageTitle}`
4242
}
4343
}
4444

src/search/lib/get-elasticsearch-results/ai-search-autocomplete.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type {
77
AutocompleteMatchQueriesOptions,
88
AutocompleteResultsArgs,
99
} from '@/search/lib/get-elasticsearch-results/types'
10-
import type { QueryDslQueryContainer, SearchTotalHits } from '@elastic/elasticsearch/lib/api/types'
10+
import type { estypes } from '@elastic/elasticsearch'
1111

1212
// Query Elasticsearch for AI Search autocomplete results
1313
export async function getAISearchAutocompleteResults({
@@ -38,7 +38,7 @@ export async function getAISearchAutocompleteResults({
3838
maxLength: 20,
3939
},
4040
})
41-
const matchQuery: QueryDslQueryContainer = {
41+
const matchQuery: estypes.QueryDslQueryContainer = {
4242
bool: {
4343
should: matchQueries,
4444
},
@@ -65,7 +65,7 @@ export async function getAISearchAutocompleteResults({
6565

6666
return {
6767
meta: {
68-
found: hitsAll.total as SearchTotalHits,
68+
found: hitsAll.total as estypes.SearchTotalHits,
6969
took: { query_msec: result.took, total_msec: new Date().getTime() - t0.getTime() },
7070
size,
7171
},
@@ -82,7 +82,7 @@ function getAISearchAutocompleteMatchQueries(
8282
const BOOST_PREFIX = 1.0
8383
const BOOST_FUZZY = 0.1
8484

85-
const matchQueries: QueryDslQueryContainer[] = []
85+
const matchQueries: estypes.QueryDslQueryContainer[] = []
8686

8787
// Use match_phrase for exact term matches
8888
matchQueries.push({

src/search/lib/get-elasticsearch-results/general-search.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@ import { getElasticsearchClient } from '@/search/lib/helpers/get-client'
22
import { DEFAULT_HIGHLIGHT_FIELDS } from '@/search/lib/search-request-params/search-params-objects'
33
import { getHighlightConfiguration } from '@/search/lib/get-elasticsearch-results/helpers/elasticsearch-highlight-config'
44

5-
import type {
6-
SearchHit as ElasticsearchHit,
7-
QueryDslQueryContainer,
8-
SearchRequest,
9-
SearchTotalHits,
10-
} from '@elastic/elasticsearch/lib/api/types'
5+
import type { estypes } from '@elastic/elasticsearch'
116
import type {
127
AdditionalIncludes,
138
ComputedSearchQueryParamsMap,
@@ -122,7 +117,7 @@ export async function getGeneralSearchResults(
122117

123118
const aggs = getAggregations(aggregate)
124119

125-
const searchQuery: SearchRequest = {
120+
const searchQuery: estypes.SearchRequest = {
126121
index: indexName,
127122
highlight,
128123
from,
@@ -198,7 +193,7 @@ export async function getGeneralSearchResults(
198193
const t1 = Date.now()
199194

200195
const meta = {
201-
found: hitsAll.total as SearchTotalHits,
196+
found: hitsAll.total as estypes.SearchTotalHits,
202197
took: {
203198
query_msec: result.took,
204199
total_msec: t1 - t0,
@@ -255,7 +250,7 @@ interface GetMatchQueriesOptions {
255250
function getMatchQueries(
256251
query: string,
257252
{ usePrefixSearch, fuzzy }: GetMatchQueriesOptions,
258-
): QueryDslQueryContainer[] {
253+
): estypes.QueryDslQueryContainer[] {
259254
const BOOST_PHRASE = 10.0
260255
const BOOST_TITLE = 4.0
261256
const BOOST_HEADINGS = 3.0
@@ -268,7 +263,7 @@ function getMatchQueries(
268263
// which wouldn't find anything else anyway.
269264
const BOOST_FUZZY = 0.1
270265

271-
const matchQueries: QueryDslQueryContainer[] = []
266+
const matchQueries: estypes.QueryDslQueryContainer[] = []
272267

273268
// If the query input is multiple words, it's good to know because you can
274269
// make the query do `match_phrase` and you can make `match` query
@@ -452,7 +447,7 @@ interface GetHitsOptions {
452447
}
453448

454449
function getHits(
455-
hits: ElasticsearchHit<any>[],
450+
hits: estypes.SearchHit<any>[],
456451
{ indexName, debug = false, includeTopics = false, highlightFields, include }: GetHitsOptions,
457452
): GeneralSearchHit[] {
458453
return hits.map((hit) => {
@@ -470,7 +465,7 @@ function getHits(
470465
}
471466

472467
const result: GeneralSearchHit = {
473-
id: hit._id,
468+
id: hit._id!,
474469
url: hit._source.url,
475470
title: hit._source.title,
476471
breadcrumbs: hit._source.breadcrumbs,

src/search/lib/get-elasticsearch-results/helpers/elasticsearch-highlight-config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { SearchHighlight } from '@elastic/elasticsearch/lib/api/types'
1+
import type { estypes } from '@elastic/elasticsearch'
22

33
import type { HighlightOptions } from '@/search/lib/search-request-params/types'
44

@@ -18,7 +18,7 @@ export type HighlightFields = {
1818
export function getHighlightConfiguration(
1919
query: string,
2020
highlightsFields: HighlightOptions[],
21-
): SearchHighlight {
21+
): estypes.SearchHighlight {
2222
const fields = {} as HighlightFields
2323
if (highlightsFields.includes('title')) {
2424
fields.title = {
@@ -76,7 +76,7 @@ export function getHighlightConfiguration(
7676
}
7777
}
7878

79-
const highlightConfig: SearchHighlight = {
79+
const highlightConfig: estypes.SearchHighlight = {
8080
pre_tags: ['<mark>'],
8181
post_tags: ['</mark>'],
8282
fields,

src/search/scripts/analyze-text.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import dotenv from 'dotenv'
1313
import { languageKeys } from '@/languages/lib/languages-server'
1414
import { allVersions } from '@/versions/lib/all-versions'
1515

16-
import type { IndicesAnalyzeAnalyzeToken } from '@elastic/elasticsearch/lib/api/types'
16+
import type { estypes } from '@elastic/elasticsearch'
1717

1818
// Now you can optionally have set the ELASTICSEARCH_URL in your .env file.
1919
dotenv.config()
@@ -157,7 +157,7 @@ async function analyzeVersion(client: Client, texts: string[], indexName: string
157157
body: { analyzer, text },
158158
})
159159

160-
const tokens: IndicesAnalyzeAnalyzeToken[] | undefined = response.tokens
160+
const tokens: estypes.IndicesAnalyzeAnalyzeToken[] | undefined = response.tokens
161161
const tokenWords: string[] = tokens?.map((token) => token.token) || []
162162
console.log(tokenWords)
163163
}

src/search/scripts/index/utils/settings.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import { SNOWBALL_LANGUAGES } from '@/search/scripts/index/utils/constants'
22

33
import type { estypes } from '@elastic/elasticsearch'
4-
import type {
5-
AnalysisSnowballLanguage,
6-
AnalysisCustomAnalyzer,
7-
} from '@elastic/elasticsearch/lib/api/types'
84

95
export function getGeneralSearchSettings(
106
language: string,
@@ -24,25 +20,26 @@ export function getGeneralSearchSettings(
2420
filter: ['lowercase', 'stop', 'asciifolding'],
2521
tokenizer: 'standard',
2622
type: 'custom',
27-
} as AnalysisCustomAnalyzer,
23+
} as estypes.AnalysisCustomAnalyzer,
2824
text_analyzer: {
2925
filter: ['lowercase', 'stop', 'asciifolding'],
3026
tokenizer: 'standard',
3127
type: 'custom',
32-
} as AnalysisCustomAnalyzer,
28+
} as estypes.AnalysisCustomAnalyzer,
3329
},
3430
filter: {},
3531
},
3632
}
3733

3834
const snowballLanguage = SNOWBALL_LANGUAGES[language]
3935
if (snowballLanguage) {
40-
const textAnalyzer = settings.analysis!.analyzer!.text_analyzer as AnalysisCustomAnalyzer
41-
textAnalyzer.filter!.push('languaged_snowball')
36+
const textAnalyzer = settings.analysis!.analyzer!
37+
.text_analyzer as estypes.AnalysisCustomAnalyzer
38+
;(textAnalyzer.filter as string[]).push('languaged_snowball')
4239

4340
settings.analysis!.filter!['languaged_snowball'] = {
4441
type: 'snowball',
45-
language: snowballLanguage as AnalysisSnowballLanguage,
42+
language: snowballLanguage as estypes.AnalysisSnowballLanguage,
4643
}
4744
} else if (verbose) {
4845
console.warn(`No snowball language for '${language}'`)
@@ -62,20 +59,21 @@ export function getAISearchAutocompleteSettings(
6259
filter: ['lowercase'],
6360
tokenizer: 'standard',
6461
type: 'custom',
65-
} as AnalysisCustomAnalyzer,
62+
} as estypes.AnalysisCustomAnalyzer,
6663
},
6764
filter: {},
6865
},
6966
}
7067

7168
const snowballLanguage = SNOWBALL_LANGUAGES[language]
7269
if (snowballLanguage) {
73-
const textAnalyzer = settings.analysis!.analyzer!.text_analyzer as AnalysisCustomAnalyzer
74-
textAnalyzer.filter!.push('languaged_snowball')
70+
const textAnalyzer = settings.analysis!.analyzer!
71+
.text_analyzer as estypes.AnalysisCustomAnalyzer
72+
;(textAnalyzer.filter as string[]).push('languaged_snowball')
7573

7674
settings.analysis!.filter!['languaged_snowball'] = {
7775
type: 'snowball',
78-
language: snowballLanguage as AnalysisSnowballLanguage,
76+
language: snowballLanguage as estypes.AnalysisSnowballLanguage,
7977
}
8078
} else if (verbose) {
8179
console.warn(`No snowball language for '${language}'`)

src/search/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { SearchTotalHits } from '@elastic/elasticsearch/lib/api/types'
1+
import type { estypes } from '@elastic/elasticsearch'
22

33
import type {
44
AdditionalIncludes,
@@ -73,7 +73,7 @@ export type SearchResultAggregations = {
7373
}
7474

7575
type SearchResultsMeta = {
76-
found: SearchTotalHits
76+
found: estypes.SearchTotalHits
7777
took: {
7878
query_msec: number
7979
total_msec: number

0 commit comments

Comments
 (0)