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

Algolia search error: Cannot read properties of undefined (reading 'lvl1') #761

Open
dariusz-wozniak opened this issue Nov 7, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@dariusz-wozniak
Copy link
Contributor

Describe the bug
When I setup the Algolia in the siteMetadata.js and want to search for something, I have the following error:

Unhandled Runtime Error
TypeError: Cannot read properties of undefined (reading 'lvl1')

Call Stack
eval
node_modules\@docsearch\react\dist\esm\DocSearchModal.js (274:0)
eval
node_modules\@docsearch\react\dist\esm\utils\groupBy.js (3:0)
Array.reduce
<anonymous>
groupBy
node_modules\@docsearch\react\dist\esm\utils\groupBy.js (2:0)
Object.getItems
node_modules\@docsearch\react\dist\esm\DocSearchModal.js (273:44)
eval
node_modules\@algolia\autocomplete-core\dist\esm\onInput.js (73:0)
Array.map
<anonymous>
eval
node_modules\@algolia\autocomplete-core\dist\esm\onInput.js (72:0)

I believe it happens when Algolia tries to find an autocomplete word:

image

To Reproduce
Using the following config:

provider: 'algolia',
algoliaConfig: {
 // The application ID provided by Algolia
 appId: 'C68MF7P5PG',
 // Public API key: it is safe to commit it
 apiKey: 'e03204dba4b4116019642e9298cb2742',
 indexName: 'dariuszwozniaknet',

System Info (if dev / build issue):

  • OS: Windows 11
  • Node version (please ensure you are using 18+): v18.18.2
  • Yarn version: 3.6.1
@dariusz-wozniak dariusz-wozniak added the bug Something isn't working label Nov 7, 2023
@timlrx
Copy link
Owner

timlrx commented Nov 11, 2023

Are you sure Algolia has correctly indexed your blog? I tried it with the example config and it works well:

algoliaConfig: {
      // The application ID provided by Algolia
      appId: 'R2IYF7ETH7',
      // Public API key: it is safe to commit it
      apiKey: '599cec31baffa4868cae4e79f180729b',
      indexName: 'docsearch',
    }

@dariusz-wozniak
Copy link
Contributor Author

dariusz-wozniak commented Nov 11, 2023

@timlrx : Yes, it works fine with these settings.

When comparing both responses:

docsearch
{
    "results": [
        {
            "hits": [
                {
                    "url": "https://docsearch.algolia.com/docs/what-is-docsearch/#quick-description",
                    "content": null,
                    "type": "lvl2",
                    "hierarchy": {
                        "lvl0": "Introduction",
                        "lvl1": "What is DocSearch?",
                        "lvl2": "Quick description​",
                        "lvl3": null,
                        "lvl4": null,
                        "lvl5": null,
                        "lvl6": null
                    },
                    "objectID": "4-https://docsearch.algolia.com/docs/what-is-docsearch/",
                    "_snippetResult": {
                        "hierarchy": {
                            "lvl1": {
                                "value": "What is DocSearch?",
                                "matchLevel": "none"
                            },
                            "lvl2": {
                                "value": "<mark>Q</mark>uick description​",
                                "matchLevel": "full"
                            }
                        }
                    },
                    "_highlightResult": {
                        "hierarchy": {
                            "lvl0": {
                                "value": "Introduction",
                                "matchLevel": "none",
                                "matchedWords": []
                            },
                            "lvl1": {
                                "value": "What is DocSearch?",
                                "matchLevel": "none",
                                "matchedWords": []
                            },
                            "lvl2": {
                                "value": "<mark>Q</mark>uick description​",
                                "matchLevel": "full",
                                "fullyHighlighted": false,
                                "matchedWords": [
                                    "q"
                                ]
                            }
                        }
                    }
                },
                {
                    "url": "https://docsearch.algolia.com/docs/legacy/behavior/#queryhook",
                    "content": null,
                    "type": "lvl2",
                    "hierarchy": {
                        "lvl0": "Adding DocSearch to your UI",
                        "lvl1": "Dropdown Behavior",
                        "lvl2": "queryHook​",
                        "lvl3": null,
                        "lvl4": null,
                        "lvl5": null,
                        "lvl6": null
                    },
                    "objectID": "7-https://docsearch.algolia.com/docs/legacy/behavior/",
                    "_snippetResult": {
                        "hierarchy": {
                            "lvl1": {
                                "value": "Dropdown Behavior",
                                "matchLevel": "none"
                            },
                            "lvl2": {
                                "value": "<mark>q</mark>ueryHook​",
                                "matchLevel": "full"
                            }
                        }
                    },
                    "_highlightResult": {
                        "hierarchy": {
                            "lvl0": {
                                "value": "Adding DocSearch to your UI",
                                "matchLevel": "none",
                                "matchedWords": []
                            },
                            "lvl1": {
                                "value": "Dropdown Behavior",
                                "matchLevel": "none",
                                "matchedWords": []
                            },
                            "lvl2": {
                                "value": "<mark>q</mark>ueryHook​",
                                "matchLevel": "full",
                                "fullyHighlighted": false,
                                "matchedWords": [
                                    "q"
                                ]
                            }
                        }
                    }
                },
                {
                    "url": "https://docsearch.algolia.com/docs/api/#initialquery",
                    "content": null,
                    "type": "lvl2",
                    "hierarchy": {
                        "lvl0": "DocSearch v3",
                        "lvl1": "API Reference",
                        "lvl2": "initialQuery​",
                        "lvl3": null,
                        "lvl4": null,
                        "lvl5": null,
                        "lvl6": null
                    },
                    "objectID": "25-https://docsearch.algolia.com/docs/api/",
                    "_snippetResult": {
                        "hierarchy": {
                            "lvl1": {
                                "value": "API Reference",
                                "matchLevel": "none"
                            },
                            "lvl2": {
                                "value": "initial<mark>Q</mark>uery​",
                                "matchLevel": "full"
                            }
                        }
                    },
                    "_highlightResult": {
                        "hierarchy": {
                            "lvl0": {
                                "value": "DocSearch v3",
                                "matchLevel": "none",
                                "matchedWords": []
                            },
                            "lvl1": {
                                "value": "API Reference",
                                "matchLevel": "none",
                                "matchedWords": []
                            },
                            "lvl2": {
                                "value": "initial<mark>Q</mark>uery​",
                                "matchLevel": "full",
                                "fullyHighlighted": false,
                                "matchedWords": [
                                    "q"
                                ]
                            }
                        }
                    }
                },
                {
                    "url": "https://docsearch.algolia.com/docs/docsearch-v3/#improve-first-query-speed",
                    "content": null,
                    "type": "lvl3",
                    "hierarchy": {
                        "lvl0": "DocSearch v3",
                        "lvl1": "Getting Started",
                        "lvl2": "Installation​",
                        "lvl3": "Improve first query speed​",
                        "lvl4": null,
                        "lvl5": null,
                        "lvl6": null
                    },
                    "objectID": "13-https://docsearch.algolia.com/docs/docsearch-v3/",
                    "_snippetResult": {
                        "hierarchy": {
                            "lvl1": {
                                "value": "Getting Started",
                                "matchLevel": "none"
                            },
                            "lvl2": {
                                "value": "Installation​",
                                "matchLevel": "none"
                            },
                            "lvl3": {
                                "value": "Improve first <mark>q</mark>uery speed​",
                                "matchLevel": "full"
                            }
                        }
                    },
                    "_highlightResult": {
                        "hierarchy": {
                            "lvl0": {
                                "value": "DocSearch v3",
                                "matchLevel": "none",
                                "matchedWords": []
                            },
                            "lvl1": {
                                "value": "Getting Started",
                                "matchLevel": "none",
                                "matchedWords": []
                            },
                            "lvl2": {
                                "value": "Installation​",
                                "matchLevel": "none",
                                "matchedWords": []
                            },
                            "lvl3": {
                                "value": "Improve first <mark>q</mark>uery speed​",
                                "matchLevel": "full",
                                "fullyHighlighted": false,
                                "matchedWords": [
                                    "q"
                                ]
                            }
                        }
                    }
                },
                {
                    "url": "https://docsearch.algolia.com/docs/legacy/faq/",
                    "content": "If you're not finding the answer to your question on this website, this page will help you. If you're still unsure, don't hesitate to send your question to us directly.",
                    "type": "content",
                    "hierarchy": {
                        "lvl0": "Requirements, tips, FAQ",
                        "lvl1": "FAQ",
                        "lvl2": null,
                        "lvl3": null,
                        "lvl4": null,
                        "lvl5": null,
                        "lvl6": null
                    },
                    "objectID": "2-https://docsearch.algolia.com/docs/legacy/faq/",
                    "_snippetResult": {
                        "content": {
                            "value": "If you're not finding the answer to your <mark>q</mark>uestion …",
                            "matchLevel": "full"
                        },
                        "hierarchy": {
                            "lvl1": {
                                "value": "FAQ",
                                "matchLevel": "none"
                            }
                        }
                    },
                    "_highlightResult": {
                        "content": {
                            "value": "If you're not finding the answer to your <mark>q</mark>uestion on this website, this page will help you. If you're still unsure, don't hesitate to send your <mark>q</mark>uestion to us directly.",
                            "matchLevel": "full",
                            "fullyHighlighted": false,
                            "matchedWords": [
                                "q"
                            ]
                        },
                        "hierarchy": {
                            "lvl0": {
                                "value": "Requirements, tips, FAQ",
                                "matchLevel": "none",
                                "matchedWords": []
                            },
                            "lvl1": {
                                "value": "FAQ",
                                "matchLevel": "none",
                                "matchedWords": []
                            }
                        }
                    }
                },
                {
                    "url": "https://docsearch.algolia.com/docs/docsearch-program/",
                    "content": "If you're not finding the answer to your question on this website, this page will help you. If you're still unsure, don't hesitate to send your question to us directly.\r\nFor questions related to the DocSearch x Algolia Crawler, please see our Crawler FAQ.",
                    "type": "content",
                    "hierarchy": {
                        "lvl0": "FAQ",
                        "lvl1": "DocSearch program",
                        "lvl2": null,
                        "lvl3": null,
                        "lvl4": null,
                        "lvl5": null,
                        "lvl6": null
                    },
                    "objectID": "2-https://docsearch.algolia.com/docs/docsearch-program/",
                    "_snippetResult": {
                        "content": {
                            "value": "… <mark>q</mark>uestion to us directly.\r\nFor <mark>q</mark>uestions related to the Doc …",
                            "matchLevel": "full"
                        },
                        "hierarchy": {
                            "lvl1": {
                                "value": "DocSearch program",
                                "matchLevel": "none"
                            }
                        }
                    },
                    "_highlightResult": {
                        "content": {
                            "value": "If you're not finding the answer to your <mark>q</mark>uestion on this website, this page will help you. If you're still unsure, don't hesitate to send your <mark>q</mark>uestion to us directly.\r\nFor <mark>q</mark>uestions related to the DocSearch x Algolia Crawler, please see our Crawler FAQ.",
                            "matchLevel": "full",
                            "fullyHighlighted": false,
                            "matchedWords": [
                                "q"
                            ]
                        },
                        "hierarchy": {
                            "lvl0": {
                                "value": "FAQ",
                                "matchLevel": "none",
                                "matchedWords": []
                            },
                            "lvl1": {
                                "value": "DocSearch program",
                                "matchLevel": "none",
                                "matchedWords": []
                            }
                        }
                    }
                },
                {
                    "url": "https://docsearch.algolia.com/docs/crawler/",
                    "content": "If you're not finding the answer to your question on this website, this page will help you. If you're still unsure, don't hesitate to send your question to us directly.\r\nYou can also read our Crawler FAQ, to understand how it behaves:\r\nOne of my pages was not crawled\r\nWhy are my pages skipped?\r\nFor questions related to the DocSearch program, please see our DocSearch program FAQ.",
                    "type": "content",
                    "hierarchy": {
                        "lvl0": "FAQ",
                        "lvl1": "DocSearch x Algolia Crawler",
                        "lvl2": null,
                        "lvl3": null,
                        "lvl4": null,
                        "lvl5": null,
                        "lvl6": null
                    },
                    "objectID": "2-https://docsearch.algolia.com/docs/crawler/",
                    "_snippetResult": {
                        "content": {
                            "value": "If you're not finding the answer to your <mark>q</mark>uestion …",
                            "matchLevel": "full"
                        },
                        "hierarchy": {
                            "lvl1": {
                                "value": "DocSearch x Algolia Crawler",
                                "matchLevel": "none"
                            }
                        }
                    },
                    "_highlightResult": {
                        "content": {
                            "value": "If you're not finding the answer to your <mark>q</mark>uestion on this website, this page will help you. If you're still unsure, don't hesitate to send your <mark>q</mark>uestion to us directly.\r\nYou can also read our Crawler FAQ, to understand how it behaves:\r\nOne of my pages was not crawled\r\nWhy are my pages skipped?\r\nFor <mark>q</mark>uestions related to the DocSearch program, please see our DocSearch program FAQ.",
                            "matchLevel": "full",
                            "fullyHighlighted": false,
                            "matchedWords": [
                                "q"
                            ]
                        },
                        "hierarchy": {
                            "lvl0": {
                                "value": "FAQ",
                                "matchLevel": "none",
                                "matchedWords": []
                            },
                            "lvl1": {
                                "value": "DocSearch x Algolia Crawler",
                                "matchLevel": "none",
                                "matchedWords": []
                            }
                        }
                    }
                },
                {
                    "url": "https://docsearch.algolia.com/docs/api/#transformsearchclient",
                    "content": "Useful for transforming the Algolia Search Client, for example to debounce search queries",
                    "type": "content",
                    "hierarchy": {
                        "lvl0": "DocSearch v3",
                        "lvl1": "API Reference",
                        "lvl2": "transformSearchClient​",
                        "lvl3": null,
                        "lvl4": null,
                        "lvl5": null,
                        "lvl6": null
                    },
                    "objectID": "22-https://docsearch.algolia.com/docs/api/",
                    "_snippetResult": {
                        "content": {
                            "value": "… the Algolia Search Client, for example to debounce search <mark>q</mark>ueries",
                            "matchLevel": "full"
                        },
                        "hierarchy": {
                            "lvl1": {
                                "value": "API Reference",
                                "matchLevel": "none"
                            },
                            "lvl2": {
                                "value": "transformSearchClient​",
                                "matchLevel": "none"
                            }
                        }
                    },
                    "_highlightResult": {
                        "content": {
                            "value": "Useful for transforming the Algolia Search Client, for example to debounce search <mark>q</mark>ueries",
                            "matchLevel": "full",
                            "fullyHighlighted": false,
                            "matchedWords": [
                                "q"
                            ]
                        },
                        "hierarchy": {
                            "lvl0": {
                                "value": "DocSearch v3",
                                "matchLevel": "none",
                                "matchedWords": []
                            },
                            "lvl1": {
                                "value": "API Reference",
                                "matchLevel": "none",
                                "matchedWords": []
                            },
                            "lvl2": {
                                "value": "transformSearchClient​",
                                "matchLevel": "none",
                                "matchedWords": []
                            }
                        }
                    }
                },
                {
                    "url": "https://docsearch.algolia.com/docs/api/#resultsfootercomponent",
                    "content": "The component to display below the search results.\r\nYou get access to the current state which allows you to retrieve the number of hits returned, the query etc.\r\nYou can find a working example without JSX in this sandbox.",
                    "type": "content",
                    "hierarchy": {
                        "lvl0": "DocSearch v3",
                        "lvl1": "API Reference",
                        "lvl2": "resultsFooterComponent​",
                        "lvl3": null,
                        "lvl4": null,
                        "lvl5": null,
                        "lvl6": null
                    },
                    "objectID": "34-https://docsearch.algolia.com/docs/api/",
                    "_snippetResult": {
                        "content": {
                            "value": "… number of hits returned, the <mark>q</mark>uery etc.\r\nYou can find …",
                            "matchLevel": "full"
                        },
                        "hierarchy": {
                            "lvl1": {
                                "value": "API Reference",
                                "matchLevel": "none"
                            },
                            "lvl2": {
                                "value": "resultsFooterComponent​",
                                "matchLevel": "none"
                            }
                        }
                    },
                    "_highlightResult": {
                        "content": {
                            "value": "The component to display below the search results.\r\nYou get access to the current state which allows you to retrieve the number of hits returned, the <mark>q</mark>uery etc.\r\nYou can find a working example without JSX in this sandbox.",
                            "matchLevel": "full",
                            "fullyHighlighted": false,
                            "matchedWords": [
                                "q"
                            ]
                        },
                        "hierarchy": {
                            "lvl0": {
                                "value": "DocSearch v3",
                                "matchLevel": "none",
                                "matchedWords": []
                            },
                            "lvl1": {
                                "value": "API Reference",
                                "matchLevel": "none",
                                "matchedWords": []
                            },
                            "lvl2": {
                                "value": "resultsFooterComponent​",
                                "matchLevel": "none",
                                "matchedWords": []
                            }
                        }
                    }
                },
                {
                    "url": "https://docsearch.algolia.com/docs/how-does-it-work/#you-apply",
                    "content": "The first thing you'll need to do is to apply for DocSearch by filling out the form on this page (double check first that you qualify). We are receiving a lot of requests, so this form makes sure we won't be forgetting anyone.\r\nWe guarantee that we will answer every request, but as we receive a lot of applications, please give us a couple of days to get back to you :)",
                    "type": "content",
                    "hierarchy": {
                        "lvl0": "Under the hood",
                        "lvl1": "How does it work?",
                        "lvl2": "You apply​",
                        "lvl3": null,
                        "lvl4": null,
                        "lvl5": null,
                        "lvl6": null
                    },
                    "objectID": "4-https://docsearch.algolia.com/docs/how-does-it-work/",
                    "_snippetResult": {
                        "content": {
                            "value": "… double check first that you <mark>q</mark>ualify). We are receiving a …",
                            "matchLevel": "full"
                        },
                        "hierarchy": {
                            "lvl1": {
                                "value": "How does it work?",
                                "matchLevel": "none"
                            },
                            "lvl2": {
                                "value": "You apply​",
                                "matchLevel": "none"
                            }
                        }
                    },
                    "_highlightResult": {
                        "content": {
                            "value": "The first thing you'll need to do is to apply for DocSearch by filling out the form on this page (double check first that you <mark>q</mark>ualify). We are receiving a lot of requests, so this form makes sure we won't be forgetting anyone.\r\nWe guarantee that we will answer every request, but as we receive a lot of applications, please give us a couple of days to get back to you :)",
                            "matchLevel": "full",
                            "fullyHighlighted": false,
                            "matchedWords": [
                                "q"
                            ]
                        },
                        "hierarchy": {
                            "lvl0": {
                                "value": "Under the hood",
                                "matchLevel": "none",
                                "matchedWords": []
                            },
                            "lvl1": {
                                "value": "How does it work?",
                                "matchLevel": "none",
                                "matchedWords": []
                            },
                            "lvl2": {
                                "value": "You apply​",
                                "matchLevel": "none",
                                "matchedWords": []
                            }
                        }
                    }
                },
                {
                    "url": "https://docsearch.algolia.com/docs/docsearch-v3/#preconnect",
                    "content": "By adding this snippet to the head of your website, you can hint the browser that the website will load data from Algolia, and allows it to preconnect to the DocSearch cluster. It makes the first query faster, especially on mobile.",
                    "type": "content",
                    "hierarchy": {
                        "lvl0": "DocSearch v3",
                        "lvl1": "Getting Started",
                        "lvl2": "Performance optimization​",
                        "lvl3": "Preconnect​",
                        "lvl4": null,
                        "lvl5": null,
                        "lvl6": null
                    },
                    "objectID": "25-https://docsearch.algolia.com/docs/docsearch-v3/",
                    "_snippetResult": {
                        "content": {
                            "value": "… cluster. It makes the first <mark>q</mark>uery faster, especially on mobile.",
                            "matchLevel": "full"
                        },
                        "hierarchy": {
                            "lvl1": {
                                "value": "Getting Started",
                                "matchLevel": "none"
                            },
                            "lvl2": {
                                "value": "Performance optimization​",
                                "matchLevel": "none"
                            },
                            "lvl3": {
                                "value": "Preconnect​",
                                "matchLevel": "none"
                            }
                        }
                    },
                    "_highlightResult": {
                        "content": {
                            "value": "By adding this snippet to the head of your website, you can hint the browser that the website will load data from Algolia, and allows it to preconnect to the DocSearch cluster. It makes the first <mark>q</mark>uery faster, especially on mobile.",
                            "matchLevel": "full",
                            "fullyHighlighted": false,
                            "matchedWords": [
                                "q"
                            ]
                        },
                        "hierarchy": {
                            "lvl0": {
                                "value": "DocSearch v3",
                                "matchLevel": "none",
                                "matchedWords": []
                            },
                            "lvl1": {
                                "value": "Getting Started",
                                "matchLevel": "none",
                                "matchedWords": []
                            },
                            "lvl2": {
                                "value": "Performance optimization​",
                                "matchLevel": "none",
                                "matchedWords": []
                            },
                            "lvl3": {
                                "value": "Preconnect​",
                                "matchLevel": "none",
                                "matchedWords": []
                            }
                        }
                    }
                },
                {
                    "url": "https://docsearch.algolia.com/docs/docsearch-program/#what-do-i-need-to-install-on-my-side",
                    "content": "You just need to implement DocSearch in your frontend with the credentials received by email when your application has been deployed.\r\nDocSearch leverages the Algolia Crawler, which offers a web interface to create, monitor, edit, start your Crawlers. If you have any questions regarding it, please see our Crawler FAQ.",
                    "type": "content",
                    "hierarchy": {
                        "lvl0": "FAQ",
                        "lvl1": "DocSearch program",
                        "lvl2": "What do I need to install on my side?​",
                        "lvl3": null,
                        "lvl4": null,
                        "lvl5": null,
                        "lvl6": null
                    },
                    "objectID": "4-https://docsearch.algolia.com/docs/docsearch-program/",
                    "_snippetResult": {
                        "content": {
                            "value": "… Crawlers. If you have any <mark>q</mark>uestions regarding it, please see …",
                            "matchLevel": "full"
                        },
                        "hierarchy": {
                            "lvl1": {
                                "value": "DocSearch program",
                                "matchLevel": "none"
                            },
                            "lvl2": {
                                "value": "What do I need to install on my side?​",
                                "matchLevel": "none"
                            }
                        }
                    },
                    "_highlightResult": {
                        "content": {
                            "value": "You just need to implement DocSearch in your frontend with the credentials received by email when your application has been deployed.\r\nDocSearch leverages the Algolia Crawler, which offers a web interface to create, monitor, edit, start your Crawlers. If you have any <mark>q</mark>uestions regarding it, please see our Crawler FAQ.",
                            "matchLevel": "full",
                            "fullyHighlighted": false,
                            "matchedWords": [
                                "q"
                            ]
                        },
                        "hierarchy": {
                            "lvl0": {
                                "value": "FAQ",
                                "matchLevel": "none",
                                "matchedWords": []
                            },
                            "lvl1": {
                                "value": "DocSearch program",
                                "matchLevel": "none",
                                "matchedWords": []
                            },
                            "lvl2": {
                                "value": "What do I need to install on my side?​",
                                "matchLevel": "none",
                                "matchedWords": []
                            }
                        }
                    }
                },
                {
                    "url": "https://docsearch.algolia.com/docs/legacy/behavior/",
                    "content": "The following references to Autocomplete.js are outdated. If you would like to try the latest version, please visit the Autocomplete documentation\r\nOur JavaScript library DocSearch.js is a wrapper of the Algolia autocomplete.js library. This library listens to every keystrokes typed in the search input, queries Algolia, and displays the results in a dropdown. Everything is already configured for you to work with DocSearch. Our UI library also exposes configuration options you can use to go even further. You will discover Algolia out of the box for documentation. Let's start the learn as you type experience.",
                    "type": "content",
                    "hierarchy": {
                        "lvl0": "Adding DocSearch to your UI",
                        "lvl1": "Dropdown Behavior",
                        "lvl2": null,
                        "lvl3": null,
                        "lvl4": null,
                        "lvl5": null,
                        "lvl6": null
                    },
                    "objectID": "2-https://docsearch.algolia.com/docs/legacy/behavior/",
                    "_snippetResult": {
                        "content": {
                            "value": "… typed in the search input, <mark>q</mark>ueries Algolia, and displays the …",
                            "matchLevel": "full"
                        },
                        "hierarchy": {
                            "lvl1": {
                                "value": "Dropdown Behavior",
                                "matchLevel": "none"
                            }
                        }
                    },
                    "_highlightResult": {
                        "content": {
                            "value": "The following references to Autocomplete.js are outdated. If you would like to try the latest version, please visit the Autocomplete documentation\r\nOur JavaScript library DocSearch.js is a wrapper of the Algolia autocomplete.js library. This library listens to every keystrokes typed in the search input, <mark>q</mark>ueries Algolia, and displays the results in a dropdown. Everything is already configured for you to work with DocSearch. Our UI library also exposes configuration options you can use to go even further. You will discover Algolia out of the box for documentation. Let's start the learn as you type experience.",
                            "matchLevel": "full",
                            "fullyHighlighted": false,
                            "matchedWords": [
                                "q"
                            ]
                        },
                        "hierarchy": {
                            "lvl0": {
                                "value": "Adding DocSearch to your UI",
                                "matchLevel": "none",
                                "matchedWords": []
                            },
                            "lvl1": {
                                "value": "Dropdown Behavior",
                                "matchLevel": "none",
                                "matchedWords": []
                            }
                        }
                    }
                },
                {
                    "url": "https://docsearch.algolia.com/docs/legacy/styling/#other-considerations",
                    "content": "The dropdown wraps selected suggestions in a .ds-cursor class. This means that you can use .ds-cursor .algolia-docsearch-suggestion--content to style the selected suggestion for example.\r\nOn small screens, DocSearch reverts to a single column layout, while is uses the two-column layout shown in the screenshot on larger screens. You can add media queries (for example @media (min-width: 768px) {}) to target different displays.",
                    "type": "content",
                    "hierarchy": {
                        "lvl0": "Adding DocSearch to your UI",
                        "lvl1": "Styling DocSearch",
                        "lvl2": "Other considerations​",
                        "lvl3": null,
                        "lvl4": null,
                        "lvl5": null,
                        "lvl6": null
                    },
                    "objectID": "10-https://docsearch.algolia.com/docs/legacy/styling/",
                    "_snippetResult": {
                        "content": {
                            "value": "… screens. You can add media <mark>q</mark>ueries (for example @media (min …",
                            "matchLevel": "full"
                        },
                        "hierarchy": {
                            "lvl1": {
                                "value": "Styling DocSearch",
                                "matchLevel": "none"
                            },
                            "lvl2": {
                                "value": "Other considerations​",
                                "matchLevel": "none"
                            }
                        }
                    },
                    "_highlightResult": {
                        "content": {
                            "value": "The dropdown wraps selected suggestions in a .ds-cursor class. This means that you can use .ds-cursor .algolia-docsearch-suggestion--content to style the selected suggestion for example.\r\nOn small screens, DocSearch reverts to a single column layout, while is uses the two-column layout shown in the screenshot on larger screens. You can add media <mark>q</mark>ueries (for example @media (min-width: 768px) {}) to target different displays.",
                            "matchLevel": "full",
                            "fullyHighlighted": false,
                            "matchedWords": [
                                "q"
                            ]
                        },
                        "hierarchy": {
                            "lvl0": {
                                "value": "Adding DocSearch to your UI",
                                "matchLevel": "none",
                                "matchedWords": []
                            },
                            "lvl1": {
                                "value": "Styling DocSearch",
                                "matchLevel": "none",
                                "matchedWords": []
                            },
                            "lvl2": {
                                "value": "Other considerations​",
                                "matchLevel": "none",
                                "matchedWords": []
                            }
                        }
                    }
                },
                {
                    "url": "https://docsearch.algolia.com/docs/legacy/required-configuration/#nice-to-have",
                    "content": "Your website should have an updated sitemap. This is key to let our crawler know what should be updated. Do not worry, we will still crawl your website and discover embedded hyperlinks to find your great content.\r\nYour website should have an updated sitemap. This is key to let our crawler know what should be updated. Do not worry, we will still crawl your website and discover embedded hyperlinks to find your great content.\r\nEvery page needs to have their full context available. Using global elements might help (see above).\r\nEvery page needs to have their full context available. Using global elements might help (see above).\r\nAny questions? Send us an email.",
                    "type": "content",
                    "hierarchy": {
                        "lvl0": "Requirements, tips, FAQ",
                        "lvl1": "Required configuration",
                        "lvl2": "Nice to have​",
                        "lvl3": null,
                        "lvl4": null,
                        "lvl5": null,
                        "lvl6": null
                    },
                    "objectID": "11-https://docsearch.algolia.com/docs/legacy/required-configuration/",
                    "_snippetResult": {
                        "content": {
                            "value": "… might help (see above).\r\nAny <mark>q</mark>uestions? Send us an email.",
                            "matchLevel": "full"
                        },
                        "hierarchy": {
                            "lvl1": {
                                "value": "Required configuration",
                                "matchLevel": "none"
                            },
                            "lvl2": {
                                "value": "Nice to have​",
                                "matchLevel": "none"
                            }
                        }
                    },
                    "_highlightResult": {
                        "content": {
                            "value": "Your website should have an updated sitemap. This is key to let our crawler know what should be updated. Do not worry, we will still crawl your website and discover embedded hyperlinks to find your great content.\r\nYour website should have an updated sitemap. This is key to let our crawler know what should be updated. Do not worry, we will still crawl your website and discover embedded hyperlinks to find your great content.\r\nEvery page needs to have their full context available. Using global elements might help (see above).\r\nEvery page needs to have their full context available. Using global elements might help (see above).\r\nAny <mark>q</mark>uestions? Send us an email.",
                            "matchLevel": "full",
                            "fullyHighlighted": false,
                            "matchedWords": [
                                "q"
                            ]
                        },
                        "hierarchy": {
                            "lvl0": {
                                "value": "Requirements, tips, FAQ",
                                "matchLevel": "none",
                                "matchedWords": []
                            },
                            "lvl1": {
                                "value": "Required configuration",
                                "matchLevel": "none",
                                "matchedWords": []
                            },
                            "lvl2": {
                                "value": "Nice to have​",
                                "matchLevel": "none",
                                "matchedWords": []
                            }
                        }
                    }
                },
                {
                    "url": "https://docsearch.algolia.com/docs/required-configuration/#nice-to-have",
                    "content": "Your website should have an updated sitemap. This is key to let our crawler know what should be updated. Do not worry, we will still crawl your website and discover embedded hyperlinks to find your great content.\r\nYour website should have an updated sitemap. This is key to let our crawler know what should be updated. Do not worry, we will still crawl your website and discover embedded hyperlinks to find your great content.\r\nEvery page needs to have their full context available. Using global elements might help (see above).\r\nEvery page needs to have their full context available. Using global elements might help (see above).\r\nAny questions? Send us an email.",
                    "type": "content",
                    "hierarchy": {
                        "lvl0": "Under the hood",
                        "lvl1": "Required configuration",
                        "lvl2": "Nice to have​",
                        "lvl3": null,
                        "lvl4": null,
                        "lvl5": null,
                        "lvl6": null
                    },
                    "objectID": "12-https://docsearch.algolia.com/docs/required-configuration/",
                    "_snippetResult": {
                        "content": {
                            "value": "… might help (see above).\r\nAny <mark>q</mark>uestions? Send us an email.",
                            "matchLevel": "full"
                        },
                        "hierarchy": {
                            "lvl1": {
                                "value": "Required configuration",
                                "matchLevel": "none"
                            },
                            "lvl2": {
                                "value": "Nice to have​",
                                "matchLevel": "none"
                            }
                        }
                    },
                    "_highlightResult": {
                        "content": {
                            "value": "Your website should have an updated sitemap. This is key to let our crawler know what should be updated. Do not worry, we will still crawl your website and discover embedded hyperlinks to find your great content.\r\nYour website should have an updated sitemap. This is key to let our crawler know what should be updated. Do not worry, we will still crawl your website and discover embedded hyperlinks to find your great content.\r\nEvery page needs to have their full context available. Using global elements might help (see above).\r\nEvery page needs to have their full context available. Using global elements might help (see above).\r\nAny <mark>q</mark>uestions? Send us an email.",
                            "matchLevel": "full",
                            "fullyHighlighted": false,
                            "matchedWords": [
                                "q"
                            ]
                        },
                        "hierarchy": {
                            "lvl0": {
                                "value": "Under the hood",
                                "matchLevel": "none",
                                "matchedWords": []
                            },
                            "lvl1": {
                                "value": "Required configuration",
                                "matchLevel": "none",
                                "matchedWords": []
                            },
                            "lvl2": {
                                "value": "Nice to have​",
                                "matchLevel": "none",
                                "matchedWords": []
                            }
                        }
                    }
                }
            ],
            "nbHits": 16,
            "page": 0,
            "nbPages": 1,
            "hitsPerPage": 20,
            "exhaustiveNbHits": true,
            "exhaustiveTypo": true,
            "exhaustive": {
                "nbHits": true,
                "typo": true
            },
            "query": "q",
            "params": "query=q&attributesToRetrieve=%5B%22hierarchy.lvl0%22%2C%22hierarchy.lvl1%22%2C%22hierarchy.lvl2%22%2C%22hierarchy.lvl3%22%2C%22hierarchy.lvl4%22%2C%22hierarchy.lvl5%22%2C%22hierarchy.lvl6%22%2C%22content%22%2C%22type%22%2C%22url%22%5D&attributesToSnippet=%5B%22hierarchy.lvl1%3A10%22%2C%22hierarchy.lvl2%3A10%22%2C%22hierarchy.lvl3%3A10%22%2C%22hierarchy.lvl4%3A10%22%2C%22hierarchy.lvl5%3A10%22%2C%22hierarchy.lvl6%3A10%22%2C%22content%3A10%22%5D&snippetEllipsisText=%E2%80%A6&highlightPreTag=%3Cmark%3E&highlightPostTag=%3C%2Fmark%3E&hitsPerPage=20&clickAnalytics=false",
            "index": "docsearch",
            "renderingContent": {},
            "processingTimeMS": 2,
            "processingTimingsMS": {
                "_request": {
                    "roundTrip": 38
                },
                "afterFetch": {
                    "format": {
                        "total": 1
                    },
                    "total": 1
                },
                "total": 2
            },
            "serverTimeMS": 3
        }
    ]
}
dariuszwozniaknet
{
    "results": [
        {
            "exhaustive": {
                "nbHits": true,
                "typo": true
            },
            "exhaustiveNbHits": true,
            "exhaustiveTypo": true,
            "hits": [
                {
                    "_highlightResult": {
                        "title": {
                            "fullyHighlighted": false,
                            "matchLevel": "full",
                            "matchedWords": [
                                "ho"
                            ],
                            "value": "<mark>Ho</mark>w to test a class that has constructor impossible to mock?"
                        }
                    },
                    "objectID": "blog/test-unmockable-ctor",
                    "type": "Blog"
                },
                {
                    "_highlightResult": {
                        "title": {
                            "fullyHighlighted": false,
                            "matchLevel": "full",
                            "matchedWords": [
                                "ho"
                            ],
                            "value": "<mark>Ho</mark>w to write unit test for a class with dependency to ServiceLocator (with example of Optimizely)?"
                        }
                    },
                    "objectID": "blog/how-to-unit-test-class-with-service-locator",
                    "type": "Blog"
                },
                {
                    "_highlightResult": {
                        "title": {
                            "fullyHighlighted": false,
                            "matchLevel": "full",
                            "matchedWords": [
                                "ho"
                            ],
                            "value": "Optimizely / Episerver: <mark>Ho</mark>w to create asset folder programmatically?"
                        }
                    },
                    "objectID": "blog/optimizely/optimizely-create-asset-programatically",
                    "type": "Blog"
                }
            ],
            "hitsPerPage": 20,
            "index": "dariuszwozniaknet",
            "nbHits": 3,
            "nbPages": 1,
            "page": 0,
            "params": "query=ho&attributesToRetrieve=%5B%22hierarchy.lvl0%22%2C%22hierarchy.lvl1%22%2C%22hierarchy.lvl2%22%2C%22hierarchy.lvl3%22%2C%22hierarchy.lvl4%22%2C%22hierarchy.lvl5%22%2C%22hierarchy.lvl6%22%2C%22content%22%2C%22type%22%2C%22url%22%5D&attributesToSnippet=%5B%22hierarchy.lvl1%3A10%22%2C%22hierarchy.lvl2%3A10%22%2C%22hierarchy.lvl3%3A10%22%2C%22hierarchy.lvl4%3A10%22%2C%22hierarchy.lvl5%3A10%22%2C%22hierarchy.lvl6%3A10%22%2C%22content%3A10%22%5D&snippetEllipsisText=%E2%80%A6&highlightPreTag=%3Cmark%3E&highlightPostTag=%3C%2Fmark%3E&hitsPerPage=20&clickAnalytics=false",
            "processingTimeMS": 1,
            "processingTimingsMS": {
                "_request": {
                    "roundTrip": 44
                }
            },
            "query": "ho",
            "renderingContent": {}
        }
    ]
}

Observations:

  • There is a correct response for my index.
  • I see there are multiple levels of search for the example docsearch, but there are no lvl1, etc. on mine.

@timlrx
Copy link
Owner

timlrx commented Nov 14, 2023

Hmm the crawler config template might not be the correct structure. I tested it based on the one that they provided: https://docsearch.algolia.com/docs/docsearch-v3/#testing but maybe it is not representative of the default scraping setting or there might be something more that needs to be done on the configuration. Let me apply for access on this repository so that I can reproduce it. In the meantime, if you manage to figure out what's the issue, do let me know!

@dariusz-wozniak
Copy link
Contributor Author

The crawler is unavailable on the free Algolia account, which can be a reason.

I believe the basic search, i.e. free account for blog indexing, needs to be integrated with the InstantSearch:

I am not familiar with the React/JS/TSX, but I have created a PR with code transition to the InstantSearch: dariusz-wozniak/dariuszwozniak.net-v2#9. I need more time to fix it, but feel free to grab the code/info from that PR (if that is useful).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants