@@ -381,6 +381,10 @@ async function indexVersion(client, indexName, version, language, sourceDirector
|
||||
breadcrumbs: { type: 'text' },
|
||||
popularity: { type: 'float' },
|
||||
intro: { type: 'text' },
|
||||
// Use 'keyword' because it's faster to index and (more importantly)
|
||||
// faster to search on. It would be different if it was something
|
||||
// users could type in into a text input.
|
||||
toplevel: { type: 'keyword' },
|
||||
},
|
||||
},
|
||||
settings,
|
||||
@@ -389,7 +393,7 @@ async function indexVersion(client, indexName, version, language, sourceDirector
|
||||
// POPULATE
|
||||
const allRecords = Object.values(records).sort((a, b) => b.popularity - a.popularity)
|
||||
const operations = allRecords.flatMap((doc) => {
|
||||
const { title, objectID, content, breadcrumbs, headings, intro } = doc
|
||||
const { title, objectID, content, breadcrumbs, headings, intro, toplevel } = doc
|
||||
const contentEscaped = escapeHTML(content)
|
||||
const headingsEscaped = escapeHTML(headings)
|
||||
const record = {
|
||||
@@ -408,6 +412,7 @@ async function indexVersion(client, indexName, version, language, sourceDirector
|
||||
// you never get a product of 0.0.
|
||||
popularity: doc.popularity + 1,
|
||||
intro,
|
||||
toplevel,
|
||||
}
|
||||
return [{ index: { _index: thisAlias } }, record]
|
||||
})
|
||||
|
||||
@@ -38,6 +38,7 @@ export default function parsePageSectionsIntoRecords(page) {
|
||||
.slice(0, breadcrumbsArray.length > 1 ? -1 : breadcrumbsArray.length)
|
||||
.join(' / ') || ''
|
||||
|
||||
const toplevel = breadcrumbsArray[0] || ''
|
||||
const objectID = href
|
||||
|
||||
const rootSelector = '[data-search=article-body]'
|
||||
@@ -91,5 +92,6 @@ export default function parsePageSectionsIntoRecords(page) {
|
||||
headings,
|
||||
content,
|
||||
intro,
|
||||
toplevel,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
"content": "This is a fixture with the silly foo word.",
|
||||
"topics": ["Test", "Fixture"],
|
||||
"popularity": 0.5,
|
||||
"intro": "Has an intro"
|
||||
"intro": "Has an intro",
|
||||
"toplevel": "Fooing"
|
||||
},
|
||||
"/en/bar": {
|
||||
"objectID": "/en/bar",
|
||||
@@ -17,7 +18,8 @@
|
||||
"content": "Can't have foo if you don't also have bar.",
|
||||
"topics": ["Test", "Fixture", "Get started"],
|
||||
"popularity": 0.6,
|
||||
"intro": "Has no intro"
|
||||
"intro": "Has no intro",
|
||||
"toplevel": "Baring"
|
||||
},
|
||||
"/en/breadcrumbless": {
|
||||
"objectID": "/en/bar",
|
||||
@@ -27,7 +29,8 @@
|
||||
"content": "Not all pages have a breadcrumb. Fact of life.",
|
||||
"topics": [],
|
||||
"popularity": 0.1,
|
||||
"intro": ""
|
||||
"intro": "",
|
||||
"toplevel": "Baring"
|
||||
},
|
||||
"/en/get-started/foo/for-playwright": {
|
||||
"objectID": "/en/get-started/foo/for-playwright",
|
||||
@@ -36,6 +39,7 @@
|
||||
"headings": "Opening",
|
||||
"content": "This page exists to serve a Playwright test to view an article page",
|
||||
"popularity": 0.5,
|
||||
"intro": "Exists for a Playwright test"
|
||||
"intro": "Exists for a Playwright test",
|
||||
"toplevel": "Fooing"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
"content": "これは、ばかげた foo ワードのフィクスチャです。",
|
||||
"topics": ["Test", "Fixture"],
|
||||
"popularity": 0.5,
|
||||
"intro": "イントロあり"
|
||||
"intro": "イントロあり",
|
||||
"toplevel": "Fooing"
|
||||
},
|
||||
"/ja/bar": {
|
||||
"objectID": "/ja/bar",
|
||||
@@ -17,7 +18,8 @@
|
||||
"content": "bar も持っていない場合、foo を持つことはできません。",
|
||||
"topics": ["Test", "Fixture", "Get started"],
|
||||
"popularity": 0.6,
|
||||
"intro": "イントロがない"
|
||||
"intro": "イントロがない",
|
||||
"toplevel": "Baring"
|
||||
},
|
||||
"/ja/breadcrumbless": {
|
||||
"objectID": "/ja/bar",
|
||||
@@ -27,6 +29,7 @@
|
||||
"content": "すべてのページにブレッドクラムがあるわけではありません。人生の事実。",
|
||||
"topics": [],
|
||||
"popularity": 0.1,
|
||||
"intro": ""
|
||||
"intro": "",
|
||||
"toplevel": "Baring"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
"headings": "",
|
||||
"content": "This is a fixture with the silly foo word. Exclusively for GHEC.",
|
||||
"topics": ["Test", "Fixture"],
|
||||
"intro": "Sample intro"
|
||||
"intro": "Sample intro",
|
||||
"toplevel": "Fooing"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
"headings": "",
|
||||
"content": "これは、ばかげた foo ワードのフィクスチャです。 GHAE専用。",
|
||||
"topics": ["Test", "Fixture"],
|
||||
"intro": "サンプル紹介"
|
||||
"intro": "サンプル紹介",
|
||||
"toplevel": "Fooing"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ describe('search parsePageSectionsIntoRecords module', () => {
|
||||
'Bullet\nPoint\nNumbered\nList\n' +
|
||||
"Further reading\nThis won't be ignored.",
|
||||
intro: 'This is an introduction to the article.',
|
||||
toplevel: 'GitHub Actions',
|
||||
}
|
||||
|
||||
expect(record).toEqual(expected)
|
||||
@@ -68,6 +69,7 @@ describe('search parsePageSectionsIntoRecords module', () => {
|
||||
headings: '',
|
||||
content: 'This is an introduction to the article.\nFirst paragraph.\nSecond paragraph.',
|
||||
intro: 'This is an introduction to the article.',
|
||||
toplevel: 'Education',
|
||||
}
|
||||
|
||||
expect(record).toEqual(expected)
|
||||
@@ -85,6 +87,7 @@ describe('search parsePageSectionsIntoRecords module', () => {
|
||||
headings: '',
|
||||
content: 'This is an introduction to the article.',
|
||||
intro: 'This is an introduction to the article.',
|
||||
toplevel: 'Education',
|
||||
}
|
||||
|
||||
expect(record).toEqual(expected)
|
||||
|
||||
Reference in New Issue
Block a user