Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search returns no results since migrating DocSearch #7647

Closed
6 of 7 tasks
joe-bell opened this issue Jun 18, 2022 · 5 comments
Closed
6 of 7 tasks

Search returns no results since migrating DocSearch #7647

joe-bell opened this issue Jun 18, 2022 · 5 comments
Labels
closed: question This issue is a user error/misunderstanding. domain: search Related to the search feature, usually Algolia

Comments

@joe-bell
Copy link

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

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
new Crawler({
  appId: "<MY-APP-ID>",
  apiKey: "<MY-API-KEY>",
  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: '<span class="algolia-docsearch-suggestion--highlight">',
      highlightPostTag: "</span>",
      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

  • I'd be willing to fix this bug myself.
@joe-bell joe-bell added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Jun 18, 2022
@Josh-Cena
Copy link
Collaborator

cc @shortcuts

@Josh-Cena Josh-Cena added domain: search Related to the search feature, usually Algolia and removed status: needs triage This issue has not been triaged by maintainers labels Jun 18, 2022
@shortcuts
Copy link
Contributor

shortcuts commented Jun 19, 2022

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 #6693 (comment) or #6693 (comment) for the solution/context.

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

@joe-bell
Copy link
Author

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

Thanks so much @shortcuts, that resolved it for me

@Josh-Cena Josh-Cena closed this as not planned Won't fix, can't repro, duplicate, stale Jun 20, 2022
@Josh-Cena Josh-Cena added closed: question This issue is a user error/misunderstanding. and removed bug An error in the Docusaurus core causing instability or issues with its execution labels Jun 20, 2022
@Josh-Cena
Copy link
Collaborator

Thanks @shortcuts!

@slorber
Copy link
Collaborator

slorber commented Apr 5, 2024

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:

  • make sure that your Algolia index has the fields in the screenshot below
  • If you don't see these fields, then you have an index config problem
  • You should check your crawler config, make sure it matches the recommended one, and then delete/recreate your index based on the newly updated/fixed crawler config (Algolia team recommendation)

image

See also: #10007 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed: question This issue is a user error/misunderstanding. domain: search Related to the search feature, usually Algolia
Projects
None yet
Development

No branches or pull requests

4 participants