typescript-cheatsheets / react

Cheatsheets for experienced React developers getting started with TypeScript

Home Page:https://react-typescript-cheatsheet.netlify.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Algolia] Invalid key

raulfdm opened this issue · comments

The search is not working.

Screenshot 2022-09-13 at 07 54 23

I'm not sure who belongs to this API key but it seems it got spired.

Thanks for reporting @raulfdm!

@sw-yx, either appId or apiKey seems to be wrong. Can you take a look?

oh apikey seems to have changed... d94250e016f0b87e299e745de0cc6c0c now

hmm @slorber i triggered a manual crawl, and i saw it crawl all the URLs - but something is wrong - there's a lot of ignored URLs, and the final index has zero records. the UI doesnt really help us figure out why this is happening.

image

hmm. docusaurus seems to be setting a double slash in the canonical
image

i removed a slash and it made a bit of progress but search still not working. sigh. ee2e36e

got more pages indexed now but search still not working

image

image

image

ok the search is working inside of algolia, but not in docusaurus. what should i be trying?

Hey

In holiday on the phone atm, can't help much

The double slash canonical url seems to be the problem, already saw this issue before.

Maybe site url/baseurl is wrong?
Remove trailing slash from site url?

I think search is broken because of that. For search issues maybe check your crawler config is up to date. @shortcuts can help

Note there was a docsearch migration earlier this year, check out blog posts.

thanks for the quick response! i removed the trailing slash already, and the indexing works now. i also read the docsearch migration post but to be honest it didnt seem relevant to my situation, it just told me to update the appid and apikey which i did.

my current problem (as per the last comment and screenshot from me) is that the index seems to be good inside of the Algolia UI, but the docusuaurus search is not working even though i have checked that the appid and api keys are the same.

have a good holiday!

Hey!

oh apikey seems to have changed... d94250e016f0b87e299e745de0cc6c0c now

On my side, I can see 9a22585d1841d2fa758da919cd08a764 being active, the other one is the default search API key (link to doc)

docusaurus seems to be setting a double slash in the canonical

Indeed! But with the ignoreCanonicalTo set to true it should only crawl one of the two and allow you to properly index your website

ok the search is working inside of algolia, but not in docusaurus. what should i be trying?

Looking at the Crawler config, it seems that it does not fully match the one we recommend, you are missing some index settings that are applied by Docusaurus to filter your search.

The easiest way to solve it to follow those steps, otherwise you can apply the missing index settings from the Algolia dashboard

thank you! for what its worth i couldnt find the recommended Crawler config, i wonder if it should be linked from 1) the Crawler UI, 2) the docusaurus docsearch docs. if it was there, i missed it

i've updated the crawler!

old crawler for posterity
new Crawler({
  appId: "J65EL4UPXZ",
  apiKey: "89957f35d0e93248b8f03f3bcdb6b8ac",
  rateLimit: 8,
  startUrls: [
    "https://react-typescript-cheatsheet.netlify.app/docs/basic/setup/",
    "https://react-typescript-cheatsheet.netlify.app/",
  ],
  renderJavaScript: true,
  sitemaps: ["https://react-typescript-cheatsheet.netlify.app/sitemap.xml"],
  exclusionPatterns: [],
  ignoreCanonicalTo: true,
  discoveryPatterns: ["https://react-typescript-cheatsheet.netlify.app/**"],
  schedule: "at 10:00 on Friday",
  actions: [
    {
      indexName: "react-typescript-cheatsheet",
      pathsToMatch: ["https://react-typescript-cheatsheet.netlify.app/docs/**"],
      recordExtractor: ({ $, helpers }) => {
        return helpers.docsearch({
          recordProps: {
            lvl1: "header h1",
            content: "article p, article li, article td:last-child",
            lvl0: {
              selectors: ".menu__link--sublist.menu__link--active",
              defaultValue: "Documentation",
            },
            lvl2: "article h2",
            lvl3: "article h3",
            lvl4: "article h4",
            lvl5: "article h5, article td:first-child",
            lvl6: "article h6",
          },
          indexHeadings: true,
        });
      },
    },
  ],
  initialIndexSettings: {
    "react-typescript-cheatsheet": {
      attributesForFaceting: ["type", "lang", "language", "version"],
      attributesToRetrieve: [
        "hierarchy",
        "content",
        "anchor",
        "url",
        "url_without_anchor",
        "type",
      ],
      attributesToHighlight: ["hierarchy", "hierarchy_camel", "content"],
      attributesToSnippet: ["content:10"],
      camelCaseAttributes: ["hierarchy", "hierarchy_radio", "content"],
      searchableAttributes: [
        "unordered(hierarchy_radio_camel.lvl0)",
        "unordered(hierarchy_radio.lvl0)",
        "unordered(hierarchy_radio_camel.lvl1)",
        "unordered(hierarchy_radio.lvl1)",
        "unordered(hierarchy_radio_camel.lvl2)",
        "unordered(hierarchy_radio.lvl2)",
        "unordered(hierarchy_radio_camel.lvl3)",
        "unordered(hierarchy_radio.lvl3)",
        "unordered(hierarchy_radio_camel.lvl4)",
        "unordered(hierarchy_radio.lvl4)",
        "unordered(hierarchy_radio_camel.lvl5)",
        "unordered(hierarchy_radio.lvl5)",
        "unordered(hierarchy_radio_camel.lvl6)",
        "unordered(hierarchy_radio.lvl6)",
        "unordered(hierarchy_camel.lvl0)",
        "unordered(hierarchy.lvl0)",
        "unordered(hierarchy_camel.lvl1)",
        "unordered(hierarchy.lvl1)",
        "unordered(hierarchy_camel.lvl2)",
        "unordered(hierarchy.lvl2)",
        "unordered(hierarchy_camel.lvl3)",
        "unordered(hierarchy.lvl3)",
        "unordered(hierarchy_camel.lvl4)",
        "unordered(hierarchy.lvl4)",
        "unordered(hierarchy_camel.lvl5)",
        "unordered(hierarchy.lvl5)",
        "unordered(hierarchy_camel.lvl6)",
        "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: "_",
    },
  },
});

as mentioned i dont think crawling is the issue. it is that i have zero visibility on why my queries are returning nothing on the frontend.

i updated the api key, but it is still returning 0 results on the docusaurus frontend even though the crawler has indexed everything correctly...

image

thank you! for what its worth i couldnt find the recommended Crawler config, i wonder if it should be linked from 1) the Crawler UI, 2) the docusaurus docsearch docs. if it was there, i missed it

Hey, indeed it's available from the Crawler UI but only at crawler creation time, otherwise it's in our docs: https://docsearch.algolia.com/docs/templates/

i updated the api key, but it is still returning 0 results on the docusaurus frontend even though the crawler has indexed everything correctly...

The last part of my previous comment should cover this issue: #547 (comment). I'm on my phone right now but let me know if you need help with that!

@sw-yx just made the update, search works on the docs!

Works like a charm. Thanks a lot for stepping in @shortcuts, much appreciated!

err thanks! for the record, based on your instructions i had no idea what to do at all. i went to both those links in the last sentence (here and here) and did not understand what i was supposed to do. maybe my fault, but just giving feedback that i was stuck even with those instructions.

err thanks! for the record, based on your instructions i had no idea what to do at all. i went to both those links in the last sentence (here and here) and did not understand what i was supposed to do. maybe my fault, but just giving feedback that i was stuck even with those instructions.

oops, I'll try to rephrase this section properly when I have time :D

ya. the problem with support is sometimes its the user being stupid, sometimes the docs/DX can be improved. hard to tell!

i work in this field so i have a lot of empathy, but also i was the dumb user here so take my professional opinion with a grain of salt, but this was a big gap even for me sincerely reading what you linked.

some thoughts:

  1. if crawler indexes 0 records, that should be treated in the UI as a bug. it shouldnt just happily sit there with 0 records, that is 99.99999% probably a bug and the UI should offer help
  2. docusaurus docsearch UI search should be reproducible in algolia in-app search and vice versa, it was maddening to find that search worked in the algolia in-app search but didnt work inside docusaurus, i looked at the API requests and didn't find anything obviously wrong, so this seemed like a source of bug/confusion
  3. was this even the right link? it didnt even seem relevant to what i was trying to do.

ya. the problem with support is sometimes its the user being stupid, sometimes the docs/DX can be improved. hard to tell!

i work in this field so i have a lot of empathy, but also i was the dumb user here so take my professional opinion with a grain of salt, but this was a big gap even for me sincerely reading what you linked.

There's a lot of places where that documentation could/should be improved, mostly because DocSearch users might not know how Algolia works at all. I've however noted that feedback and will rephrase once I have a bit of time :D

some thoughts:

  1. if crawler indexes 0 records, that should be treated in the UI as a bug. it shouldnt just happily sit there with 0 records, that is 99.99999% probably a bug and the UI should offer help

It's actually the case, if compares it with the previous Crawl but if the previous one outputs 0 records then... there's no bug :D

Here the issue is more about index settings, we've made a decision in the Crawler to only apply them at index creation time, as the Dashboard should be the source of truth. In the case of DocSearch, it's a bit wrong as user don't go to it usually, we should always re-apply them indeed to prevent users being lost. We need to re-discuss that with the team indeed.

  1. docusaurus docsearch UI search should be reproducible in algolia in-app search and vice versa, it was maddening to find that search worked in the algolia in-app search but didnt work inside docusaurus, i looked at the API requests and didn't find anything obviously wrong, so this seemed like a source of bug/confusion

As you've seen it's possible via the Search preview, but in the case of Docusaurus, filters are applied but users are not really aware of it/how they are, so it's harder for you to reproduce.

  1. was this even the right link? it didnt even seem relevant to what i was trying to do.

I might've provided too many links here, but the most important one should be: https://docsearch.algolia.com/docs/crawler/#search-yield-no-results. I should provide a TLDR for a easy solution