diff --git a/site/search/SearchPanel.tsx b/site/search/SearchPanel.tsx
index e768da341d7..179094ef02b 100644
--- a/site/search/SearchPanel.tsx
+++ b/site/search/SearchPanel.tsx
@@ -1,5 +1,5 @@
import ReactDOM from "react-dom"
-import React, { useCallback, useEffect, useState } from "react"
+import React, { useCallback, useEffect, useMemo, useState } from "react"
import cx from "classnames"
import {
keyBy,
@@ -7,6 +7,7 @@ import {
get,
mapValues,
isElementHidden,
+ sortBy,
} from "@ourworldindata/utils"
import {
InstantSearch,
@@ -36,6 +37,7 @@ import {
searchCategoryFilters,
IPageHit,
pageTypeDisplayNames,
+ PageRecord,
} from "./searchTypes.js"
import { EXPLORERS_ROUTE_FOLDER } from "../../explorer/ExplorerConstants.js"
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome/index.js"
@@ -54,6 +56,7 @@ import {
DEFAULT_GRAPHER_WIDTH,
} from "@ourworldindata/grapher"
import { SiteAnalytics } from "../SiteAnalytics.js"
+import { extractRegionNamesFromSearchQuery } from "./SearchUtils.js"
const siteAnalytics = new SiteAnalytics()
@@ -261,6 +264,13 @@ interface SearchResultsProps {
query: string
}
+const PAGES_ATTRIBUTES_TO_SEARCH_NO_FULLTEXT: (keyof PageRecord)[] = [
+ "title",
+ "excerpt",
+ "tags",
+ "authors",
+] // Should be a subset of the `searchableAttributes` set up in `configureAlgolia` for the `pages` index; minus the "content" attribute
+
const SearchResults = (props: SearchResultsProps) => {
const {
results: { queryID },
@@ -333,6 +343,12 @@ const SearchResults = (props: SearchResultsProps) => {
document.addEventListener("click", handleHitClick)
return () => document.removeEventListener("click", handleHitClick)
}, [queryID, handleHitClick])
+
+ const searchQueryRegionsMatches = useMemo(() => {
+ const extractedRegions = extractRegionNamesFromSearchQuery(props.query)
+ if (!extractedRegions) return undefined
+ return sortBy(extractedRegions, (r) => r.name) // For some deterministic order
+ }, [props.query])
if (isHidden) return null
const hasClickAnalyticsConsent = getPreferenceValue(
@@ -343,37 +359,44 @@ const SearchResults = (props: SearchResultsProps) => {
className="search-results"
data-active-filter={activeCategoryFilter}
>
- {/* This is using the InstantSearch index specified in InstantSearchContainer */}
-
-
-
-
-
- Research & Writing
-
-
+
+
+
+
+
+ Research & Writing
+
+
+
+
-
-
-
-
+
+
+