Skip to content

Commit

Permalink
refactor(algolia): remove old explorer indexing code
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelgerber committed Apr 15, 2024
1 parent f0346a3 commit 83f26be
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 243 deletions.
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,6 @@ reindex: itsJustJavascript
node --enable-source-maps itsJustJavascript/baker/algolia/configureAlgolia.js
node --enable-source-maps itsJustJavascript/baker/algolia/indexToAlgolia.js
node --enable-source-maps itsJustJavascript/baker/algolia/indexChartsToAlgolia.js
node --enable-source-maps itsJustJavascript/baker/algolia/indexExplorersToAlgolia.js
node --enable-source-maps itsJustJavascript/baker/algolia/indexExplorerViewsToAlgolia.js

clean:
Expand Down
21 changes: 0 additions & 21 deletions baker/algolia/configureAlgolia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,24 +130,6 @@ export const configureAlgolia = async () => {
disablePrefixOnAttributes: ["content"],
})

const explorersIndex = client.initIndex(
getIndexName(SearchIndexName.Explorers)
)

await explorersIndex.setSettings({
...baseSettings,
searchableAttributes: [
"unordered(slug)",
"unordered(title)",
"unordered(subtitle)",
"unordered(text)",
],
customRanking: ["desc(views_7d)"],
attributeForDistinct: "slug",
attributesForFaceting: [],
disableTypoToleranceOnAttributes: ["text"],
})

const explorerViewsIndex = client.initIndex(
getIndexName(SearchIndexName.ExplorerViews)
)
Expand Down Expand Up @@ -334,9 +316,6 @@ export const configureAlgolia = async () => {
await chartsIndex.saveSynonyms(algoliaSynonyms, {
replaceExistingSynonyms: true,
})
await explorersIndex.saveSynonyms(algoliaSynonyms, {
replaceExistingSynonyms: true,
})
await explorerViewsIndex.saveSynonyms(algoliaSynonyms, {
replaceExistingSynonyms: true,
})
Expand Down
10 changes: 9 additions & 1 deletion baker/algolia/indexExplorerViewsToAlgolia.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as db from "../../db/db.js"
import { ExplorerBlockGraphers } from "./indexExplorersToAlgolia.js"
import { DecisionMatrix } from "../../explorer/ExplorerDecisionMatrix.js"
import { tsvFormat } from "d3-dsv"
import {
Expand All @@ -15,6 +14,15 @@ import { SearchIndexName } from "../../site/search/searchTypes.js"
import { groupBy, keyBy, orderBy } from "lodash"
import { MarkdownTextWrap } from "@ourworldindata/components"

export type ExplorerBlockGraphers = {
type: "graphers"
block: {
title?: string
subtitle?: string
grapherId?: number
}[]
}

interface ExplorerViewEntry {
viewTitle: string
viewSubtitle: string
Expand Down
209 changes: 0 additions & 209 deletions baker/algolia/indexExplorersToAlgolia.ts

This file was deleted.

11 changes: 0 additions & 11 deletions site/search/searchTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,6 @@ export type IExplorerViewHit = Hit<BaseHit> & {
viewTitleIndexWithinExplorer: number
}

export type IExplorerHit = Hit<BaseHit> & {
objectID: string
slug: string
subtitle: string
text: string
title: string
views_7d: number
}

export interface ChartRecord {
objectID: string
chartId: number
Expand All @@ -83,7 +74,6 @@ export interface ChartRecord {
export type IChartHit = Hit<BaseHit> & ChartRecord

export enum SearchIndexName {
Explorers = "explorers",
ExplorerViews = "explorer-views",
Charts = "charts",
Pages = "pages",
Expand All @@ -101,6 +91,5 @@ export const searchCategoryFilters: [string, SearchCategoryFilter][] = [
export const indexNameToSubdirectoryMap: Record<SearchIndexName, string> = {
[SearchIndexName.Pages]: "",
[SearchIndexName.Charts]: "/grapher",
[SearchIndexName.Explorers]: "/explorers",
[SearchIndexName.ExplorerViews]: "/explorers",
}

0 comments on commit 83f26be

Please sign in to comment.