facebook / docusaurus

Easy to maintain open source documentation websites.
https://docusaurus.io
MIT License
56.14k stars 8.43k forks source link

Search returns no results since migrating DocSearch #7647

Closed joe-bell closed 2 years ago

joe-bell commented 2 years ago

Have you read the Contributing Guidelines on issues?

Prerequisites

Description

Prior to the DocSearch migration, plaiceholder.co's search integration worked seamlessly

Since upgrading, I've been unable to get the search up and running again for over a week now – this is my resort! I've followed steps in #4872, #6693 and the migration guide, with no luck.

Additional context to the repro provided:

Crawler Config ```ts new Crawler({ appId: "", apiKey: "", rateLimit: 8, startUrls: ["https://plaiceholder.co/docs", "https://plaiceholder.co/"], sitemaps: ["https://plaiceholder.co/docs/sitemap.xml"], ignoreCanonicalTo: true, discoveryPatterns: ["https://plaiceholder.co/**"], actions: [ { indexName: "plaiceholder", pathsToMatch: ["https://plaiceholder.co/**"], recordExtractor: ({ $, helpers }) => { // priority order: deepest active sub list header -> navbar active item -> 'Documentation' const lvl0 = $( ".menu__link.menu__link--sublist.menu__link--active, .navbar__item.navbar__link--active" ) .last() .text() || "Documentation"; return helpers.docsearch({ recordProps: { lvl0: { selectors: "", defaultValue: lvl0, }, lvl1: ["header h1", "article h1"], lvl2: "article h2", lvl3: "article h3", lvl4: "article h4", lvl5: "article h5, article td:first-child", lvl6: "article h6", content: "article p, article li, article td:last-child", }, indexHeadings: true, aggregateContent: true, recordVersion: "v3", }); }, }, ], initialIndexSettings: { plaiceholder: { attributesForFaceting: [ "type", "lang", "language", "version", "docusaurus_tag", ], attributesToRetrieve: [ "hierarchy", "content", "anchor", "url", "url_without_anchor", "type", ], attributesToHighlight: ["hierarchy", "content"], attributesToSnippet: ["content:10"], camelCaseAttributes: ["hierarchy", "content"], searchableAttributes: [ "unordered(hierarchy.lvl0)", "unordered(hierarchy.lvl1)", "unordered(hierarchy.lvl2)", "unordered(hierarchy.lvl3)", "unordered(hierarchy.lvl4)", "unordered(hierarchy.lvl5)", "unordered(hierarchy.lvl6)", "content", ], distinct: true, attributeForDistinct: "url", customRanking: [ "desc(weight.pageRank)", "desc(weight.level)", "asc(weight.position)", ], ranking: [ "words", "filters", "typo", "attribute", "proximity", "exact", "custom", ], highlightPreTag: '', highlightPostTag: "", minWordSizefor1Typo: 3, minWordSizefor2Typos: 7, allowTyposOnNumericTokens: false, minProximity: 1, ignorePlurals: true, advancedSyntax: true, attributeCriteriaComputedByMinProximity: true, removeWordsIfNoResults: "allOptional", separatorsToIndex: "_", }, }, }); ```

I love using Docusaurus, so I'd really appreciate any support to get this up and running again

Reproducible demo

https://github.com/joe-bell/plaiceholder/tree/main/docs

Steps to reproduce

  1. Visit https://plaiceholder.co/docs
  2. Click on the search bar, or visit /docs/search
  3. Enter get (this did return results prior to upgrade)
  4. Enter any combination of letters or numbers
  5. See that no results are returned

Expected behavior

In Algolia's Crawler editor page, I'm able to see that this should return results:

CleanShot 2022-06-18 at 09 36 29@2x

Actual behavior

Typing get (or any search) returns no results

CleanShot 2022-06-18 at 09 32 27@2x

Your environment

Self-service

Josh-Cena commented 2 years ago

cc @shortcuts

shortcuts commented 2 years ago

Hey, looking at the requests sent, contextualSearch option is set to true on the Docusaurus side but your Crawler config has changed (you can see the warning message on 1st screenshot) to a Docusaurus v2 config

This is indeed related to the issue you've linked, you can follow both https://github.com/facebook/docusaurus/issues/6693#issuecomment-1158568333 or https://github.com/facebook/docusaurus/issues/6693#issuecomment-1158639529 for the solution/context.

TLDR: Delete Algolia index from the dashboard and start a new crawl

joe-bell commented 2 years ago

Wow, a classic case of "turn it off and on again" 🙈

Thanks so much @shortcuts, that resolved it for me

Josh-Cena commented 2 years ago

Thanks @shortcuts!

slorber commented 6 months ago

EDIT: see Troubleshooting section added to our docs here:

https://docusaurus.io/docs/search#algolia-troubleshooting

No search result?

For anyone passing by, if you don't get any Algolia search results:

image

See also: https://github.com/facebook/docusaurus/discussions/10007#discussioncomment-9021352