#community-help

Keyword Highlighting Issue on Docusaurus with Typesense

TLDR Inas experienced trouble with keyword highlighting on a Docusaurus doc site using Typesense. After a detailed discussion, Jason clarified that the desired functionality isn't possible to implement in a cross-browser compatible way without modifications to Docusaurus core.

Powered by Struct AI
+11
12
15mo
Solved
Join the chat
Jun 14, 2022 (15 months ago)
Inas
Photo of md5-7272dfc01bbf41d0a7fb6a815d2a217a
Inas
12:30 AM
Hi there, I have integrated TS with a Docusaurus doc site. Everything follows this guide https://typesense.org/docs/guide/docsearch.html#option-a-docusaurus-powered-sites

It works, but how can I show highlight of search keyword?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
12:31 AM
Hmm, you should see highlights without any additional configuration.
12:32
Jason
12:32 AM
Could you look at the network requests for search requests made when typing a keyword and post a screenshot of the query parameters sent to Typesense?
12:32
Jason
12:32 AM
Also, may I know which version of Typesense Server you're using?
Inas
Photo of md5-7272dfc01bbf41d0a7fb6a815d2a217a
Inas
12:33 AM
Sure,

{
    "searches": [
        {
            "collection": "docs",
            "q": "openapi",
            "query_by": "hierarchy.lvl0,hierarchy.lvl1,hierarchy.lvl2,hierarchy.lvl3,hierarchy.lvl4,hierarchy.lvl5,hierarchy.lvl6,content",
            "include_fields": "hierarchy.lvl0,hierarchy.lvl1,hierarchy.lvl2,hierarchy.lvl3,hierarchy.lvl4,hierarchy.lvl5,hierarchy.lvl6,content,anchor,url,type,id",
            "highlight_full_fields": "hierarchy.lvl0,hierarchy.lvl1,hierarchy.lvl2,hierarchy.lvl3,hierarchy.lvl4,hierarchy.lvl5,hierarchy.lvl6,content",
            "group_by": "url",
            "group_limit": 3,
            "filter_by": "language:=en && docusaurus_tag:=[default,docs-default-1.5.0.dev]"
        }
    ]
}
12:35
Inas
12:35 AM
We are using docker Typesense 0.23.0
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
12:39 AM
Hmm, that should work... could you look at the response for that search request and see if there's a highlights key under each hit?
Inas
Photo of md5-7272dfc01bbf41d0a7fb6a815d2a217a
Inas
12:39 AM
Highlight on search UI works but I want to show keyword highlight after user selected doc from search UI
12:40
Inas
12:40 AM
Is that possible?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
12:40 AM
Ahh, that is not possible to do
Inas
Photo of md5-7272dfc01bbf41d0a7fb6a815d2a217a
Inas
12:44 AM
I see, seems like Algolia search on docusaurus.io does not support it too.

Thanks Jason for the answer 🙂
+11
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
12:45 AM
Yeah, docusaurus would have to implement something in the core to allow a keyword passed in a query param to be highlighted on a page when rendered. Without that, it's not possible to do this in a cross-browser compatible way from the search plugin