Docusaurus: Algolia search does not find code in code blocks?

Created on 30 Jul 2020  路  11Comments  路  Source: facebook/docusaurus

馃悰 Bug Report

Search for beforeDefaultRemarkPlugins

This term exist here in a code block: https://v2.docusaurus.io/docs/using-plugins/#docusaurusplugin-content-blog

bug

Most helpful comment

馃憢 @slorber and @anshulrgoyal,

I am part of the DocSearch team.

Usually we do not recommend indexing code samples. These samples are often very similar and duplicated along your documentation such as examples. It introduces noise to the user experience. Displaying matching code would require to enlarge the snippeting to give the context of the matching token.
There is also room for improvement in the way we handle special characters such as dot and dash that can鈥檛 be interpreted as separators yet. This is an improvement that we鈥檙e investigating on.

All 11 comments

@francoischalifour any idea?

the code block is not scrapped by default

u need to add it scrap config

馃憢 @slorber and @anshulrgoyal,

I am part of the DocSearch team.

Usually we do not recommend indexing code samples. These samples are often very similar and duplicated along your documentation such as examples. It introduces noise to the user experience. Displaying matching code would require to enlarge the snippeting to give the context of the matching token.
There is also room for improvement in the way we handle special characters such as dot and dash that can鈥檛 be interpreted as separators yet. This is an improvement that we鈥檙e investigating on.

Hi @s-pace,
I am trying to build an offline search feature for docusaurus. Here is the PR https://github.com/facebook/docusaurus/pull/3153 and https://deploy-preview-3153--docusaurus-2.netlify.app are deployed link. It would be great if u can give some feedback.

Hi @s-pace

Wonder if you have an idea to index correctly API items that are only found in code-block? Do we rather document everything outside of code blocks too?

I would definitely recommend to document all API items outside of code-block. It enables a better UX to redirect end users with scrolling to the exact matching item. It also helps to give the context of the matching item when the search query is matching the description of the API item. Last but not least, the relevancy would be better since matching a lvl3 / <h3/> element has a stronger impact on the ranking formula.

Thanks

Closing this, but we'll need to document better some attributes that are only found in code blocks

馃憢 @slorber
Just a follow up that thanks to algolia/docsearch-configs@cfc57386b1e8845231468b5206ca55829ba0d263 we are now indexing CLI options such as --skip-build
image

thanks

wonder what you can do for the original usecase I had ^^ (beforeDefaultRemarkPlugins)

馃憢 @slorber

beforeDefaultRemarkPlugins is too much present within the page. Elements matching [class^='codeBlockContent_'] selector are too similar and it degrades the search experience. Last but not least, we recommend that selectors match small piece of text to enhance the relevancy. These code blocks are too long.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MoogyG picture MoogyG  路  3Comments

ericnakagawa picture ericnakagawa  路  3Comments

omry picture omry  路  3Comments

sebqq picture sebqq  路  3Comments

endiliey picture endiliey  路  3Comments