#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

1

12
19mo
Solved
Join the chat
Jun 14, 2022 (19 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 🙂

1

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

Typesense

Lightning-fast, open source search engine for everyone | Knowledge Base powered by Struct.AI

Indexed 3011 threads (79% resolved)

Join Our Community

Similar Threads

Issues with migrating search from Algolia to Typesense

Nacho encountered issues with migrating search from Algolia to Typesense, including a custom component that interfered with the search and an incorrect element being used as the title. Jason provided guidance on removing the component and adjusting search configuration.

6

116
10mo
Solved

Typesense Integration Issue in Docusaurus

Benjamin experienced an error implementing Typesense (TS) in Docusaurus. Jason identified the correct placement of the 'typesense' key within the 'themeConfig' within the docusaurus config file, resolving the issue.

7

19
17mo
Solved

Docusaurus Integration - Search Results Ordering & Missing Highlight

Abhishek reported issues with search result ordering and missing highlights in docusaurus integration. Jason explained the result differences between modal and search page. Abhishek submitted a fix for the highlight issue.

13
9mo
Solved

Configuring Docusaurus and Typesense for a Documentation Site

Apoorv had trouble adding search functionality to a Docusaurus documentation website with Typesense. Jason worked through several troubleshooting steps, identified issues with Apoorv's setup, and ultimately provided solutions that successfully implemented the search bar function.

1

69
29mo
Solved

Issues with Typesense Search Results and Upcoming Enhancements

Stefan encountered problems with Typesense search results. Kishore Nallan recently refracted the text matching engine to improve this issue, highlighted upcoming features in their 0.23.0 release, and offered Dan a RC test run. Upgrades were also made on Typesense Cloud UI by Jason.

6

11
20mo
Solved