Skip to content

Tweak docs search ranking#915

Merged
pokey merged 11 commits intomainfrom
pokey/tweak-doc-search-ranking
Sep 7, 2022
Merged

Tweak docs search ranking#915
pokey merged 11 commits intomainfrom
pokey/tweak-doc-search-ranking

Conversation

@pokey
Copy link
Member

@pokey pokey commented Aug 16, 2022

Tweaks docs search so that we

  • prefer to search within the same lvl0 (eg "For users" vs "For contributors"), and
  • prefer docs that are not api docs, as these are a bit noisy.

Note that this PR "swizzles" a Docusaurus core class, because there doesn't seem to be any other way to create context-aware search rankings. For the actual change we made to the docusaurus core class, see 5a2a365. Note that we would like to un-swizzle the component so that we can un-pin Docusaurus; see #931

This PR also captures the crawler / index settings that live in the Algolia console today. See #917 for how we plan to make the files in source control the source of truth in the future. You can see the actual changes that were made in the search console to improve search ranking in b37cd16

To try out the new search rankings, pop up the search widget in the deploy preview at https://deploy-preview-915--cursorless.netlify.app/docs/

Fixes #644

Before

164753938-cde8c7e0-2db0-4e30-b68b-3a531345482d

After

image

Checklist

@pokey pokey force-pushed the pokey/tweak-doc-search-ranking branch 2 times, most recently from acd5357 to 5f988c4 Compare August 16, 2022 17:05
@pokey pokey force-pushed the pokey/tweak-doc-search-ranking branch from 5f988c4 to 5a2a365 Compare August 16, 2022 17:07
@@ -0,0 +1,208 @@
import React, {useState, useRef, useCallback, useMemo} from 'react';
Copy link
Member Author

@pokey pokey Aug 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this file was "swizzled" from a Docusaurus core class, because there doesn't seem to be any other way to create context-aware search rankings. For the actual change we made to the docusaurus core class, see 5a2a365

)
.last()
.text() || "Documentation";
$(".navbar__item.navbar__link--active").last().text() ||
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The menu selector that came with the default setup was doing really weird things, and we prefer to just use "For users" vs "For contributors" as the lvl0 of the hierarchy so that we can use it for search faceting, eg to downrank contributor docs when viewing user docs and vice-versa

Comment on lines +18 to +22
const isApi = $(".menu__link.menu__link--active")
.toArray()
.some((element) => $(element).text() === "API")
? "yes"
: "no";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allows us to down-rank api docs

defaultValue: lvl0,
},
lvl1: "header h1",
lvl1: "article h1",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason the default selector here was buggy, and only worked if title was defined in frontmatter, not when it was just an h1 tag, as is the case for most of our docs

@@ -0,0 +1,129 @@
new Crawler({
Copy link
Member Author

@pokey pokey Aug 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this file was dumped from the search console after a bit of tweaking to improve rankings. To see the actual changes made, see b37cd1

@pokey pokey force-pushed the pokey/tweak-doc-search-ranking branch 2 times, most recently from 61c571a to b834829 Compare August 16, 2022 20:39
@pokey pokey force-pushed the pokey/tweak-doc-search-ranking branch from b834829 to d4d1fe2 Compare August 16, 2022 20:40
@pokey pokey merged commit 3c41868 into main Sep 7, 2022
@pokey pokey deleted the pokey/tweak-doc-search-ranking branch September 7, 2022 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tweak search rankings in documentation

2 participants