Skip to content

Commit

Permalink
delete customRanking (github#24659)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbe authored Jan 27, 2022
1 parent 9141a37 commit 3c579b4
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 43 deletions.
3 changes: 0 additions & 3 deletions script/search/lunr-search-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import lunrJa from 'lunr-languages/lunr.ja.js'
import lunrEs from 'lunr-languages/lunr.es.js'
import lunrPt from 'lunr-languages/lunr.pt.js'
import fs from 'fs/promises'
import rank from './rank.js'
import validateRecords from './validate-records.js'
import { compress } from '../../lib/search/compress.js'

Expand All @@ -25,7 +24,6 @@ export default class LunrIndex {

// Add custom rankings
this.records = records.map((record) => {
record.customRanking = rank(record)
return record
})

Expand Down Expand Up @@ -62,7 +60,6 @@ export default class LunrIndex {
this.field('title', { boost: 5 })
this.field('content')
this.field('topics')
this.field('customRanking')

this.metadataWhitelist = ['position']

Expand Down
18 changes: 0 additions & 18 deletions script/search/rank.js

This file was deleted.

9 changes: 2 additions & 7 deletions script/search/validate-records.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node
import assert from 'assert'
import { isArray, isString, inRange } from 'lodash-es'
import { isArray, isString } from 'lodash-es'
import countArrayValues from 'count-array-values'

export default function validateRecords(name, records) {
Expand All @@ -10,7 +10,7 @@ export default function validateRecords(name, records) {
// each ID is unique
const objectIDs = records.map((record) => record.objectID)
const dupes = countArrayValues(objectIDs)
.filter(({ value, count }) => count > 1)
.filter(({ count }) => count > 1)
.map(({ value }) => value)
assert(!dupes.length, `every objectID must be unique. dupes: ${dupes.join('; ')}`)

Expand All @@ -24,11 +24,6 @@ export default function validateRecords(name, records) {
isString(record.title) && record.title.length,
`title must be a string. received: ${record.title}, ${JSON.stringify(record)}`
)

assert(
inRange(record.customRanking, 0, 4),
`customRanking must be an in-range number. received: ${record.customRanking}, (record: ${record.url})`
)
})

return true
Expand Down
15 changes: 0 additions & 15 deletions tests/unit/search/rank.js

This file was deleted.

0 comments on commit 3c579b4

Please sign in to comment.