#community-help

Docusaurus Integration - Search Results Ordering & Missing Highlight

TLDR 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.

Powered by Struct AI
13
7mo
Solved
Join the chat
Mar 03, 2023 (7 months ago)
Abhishek
Photo of md5-39b08f19a4a6e14122188814743e5c3e
Abhishek
06:47 PM
Help with search results ordering in docusaurus integration 🧵
06:48
Abhishek
06:48 PM
search term - audit trail
result json -
{
  "results": [
    {
      "facet_counts": [],
      "found": 5,
      "grouped_hits": [
        {
          "group_key": [
            ""
          ],
          "hits": [
            {
              "document": {
                "anchor": "docusaurus-base-url-issue-banner-container",
                "content": "Audit Trail",
                "hierarchy": {
                  "lvl0": "Your Clerky Account",
                  "lvl1": null,
                  "lvl2": null,
                  "lvl3": null,
                  "lvl4": null,
                  "lvl5": null,
                  "lvl6": null
                },
                "hierarchy.lvl0": "Your Clerky Account",
                "id": "10",
                "type": "content",
                "url": ""
              },
              "highlight": {
                "content": {
                  "matched_tokens": [
                    "Audit",
                    "Trail"
                  ],
                  "snippet": "<mark>Audit</mark> <mark>Trail</mark>",
                  "value": "<mark>Audit</mark> <mark>Trail</mark>"
                }
              },
              "highlights": [
                {
                  "field": "content",
                  "matched_tokens": [
                    "Audit",
                    "Trail"
                  ],
                  "snippet": "<mark>Audit</mark> <mark>Trail</mark>",
                  "value": "<mark>Audit</mark> <mark>Trail</mark>"
                }
              ],
              "text_match": 1157451471441625000,
              "text_match_info": {
                "best_field_score": "2211897868544",
                "best_field_weight": 8,
                "fields_matched": 1,
                "score": "1157451471441625153",
                "tokens_matched": 2
              }
            }
          ]
        },
        {
          "group_key": [
            ""
          ],
          "hits": [
            {
              "document": {
                "anchor": "audit-trail",
                "content": "Your Clerky Account: Audit Trails",
                "hierarchy": {
                  "lvl0": "Audit Trail ​",
                  "lvl1": null,
                  "lvl2": null,
                  "lvl3": null,
                  "lvl4": null,
                  "lvl5": null,
                  "lvl6": null
                },
                "hierarchy.lvl0": "Audit Trail ​",
                "id": "14",
                "type": "content",
                "url": ""
              },
              "highlight": {
                "content": {
                  "matched_tokens": [
                    "Audit",
                    "Trail"
                  ],
                  "snippet": "Your Clerky Account: <mark>Audit</mark> <mark>Trail</mark>s",
                  "value": "Your Clerky Account: <mark>Audit</mark> <mark>Trail</mark>s"
                }
              },
              "highlights": [
                {
                  "field": "content",
                  "matched_tokens": [
                    "Audit",
                    "Trail"
                  ],
                  "snippet": "Your Clerky Account: <mark>Audit</mark> <mark>Trail</mark>s",
                  "value": "Your Clerky Account: <mark>Audit</mark> <mark>Trail</mark>s"
                }
              ],
              "text_match": 1157451471441100800,
              "text_match_info": {
                "best_field_score": "2211897868288",
                "best_field_weight": 15,
                "fields_matched": 2,
                "score": "1157451471441100922",
                "tokens_matched": 2
              }
            },
            {
              "document": {
                "anchor": "audit-trail",
                "content": "Audit trails help you monitor activity in your workspace by tracking who changed what and when. Depending on what you're looking at, an audit trail can appear as a sidebar menu or as an option in a  More (...)  menu",
                "hierarchy": {
                  "lvl0": "Audit Trail ​",
                  "lvl1": null,
                  "lvl2": null,
                  "lvl3": null,
                  "lvl4": null,
                  "lvl5": null,
                  "lvl6": null
                },
                "hierarchy.lvl0": "Audit Trail ​",
                "id": "13",
                "type": "content",
                "url": ""
              },
              "highlight": {
                "content": {
                  "matched_tokens": [
                    "Audit",
                    "trail"
                  ],
                  "snippet": "<mark>Audit</mark> <mark>trail</mark>s help you monitor activity",
                  "value": "<mark>Audit</mark> <mark>trail</mark>s help you monitor activity in your workspace by tracking who changed what and when. Depending on what you're looking at, an <mark>audit</mark> <mark>trail</mark> can appear as a sidebar menu or as an option in a  More (...)  menu"
                }
              },
              "highlights": [
                {
                  "field": "content",
                  "matched_tokens": [
                    "Audit",
                    "trail"
                  ],
                  "snippet": "<mark>Audit</mark> <mark>trail</mark>s help you monitor activity",
                  "value": "<mark>Audit</mark> <mark>trail</mark>s help you monitor activity in your workspace by tracking who changed what and when. Depending on what you're looking at, an <mark>audit</mark> <mark>trail</mark> can appear as a sidebar menu or as an option in a  More (...)  menu"
                }
              ],
              "text_match": 1157451471441100800,
              "text_match_info": {
                "best_field_score": "2211897868288",
                "best_field_weight": 15,
                "fields_matched": 2,
                "score": "1157451471441100922",
                "tokens_matched": 2
              }
            },
            {
              "document": {
                "anchor": "audit-trail",
                "hierarchy": {
                  "lvl0": "Audit Trail ​",
                  "lvl1": null,
                  "lvl2": null,
                  "lvl3": null,
                  "lvl4": null,
                  "lvl5": null,
                  "lvl6": null
                },
                "hierarchy.lvl0": "Audit Trail ​",
                "id": "12",
                "type": "lvl0",
                "url": ""
              },
              "highlight": {
                "hierarchy": {
                  "lvl0": "Audit Trail ​",
                  "lvl1": null,
                  "lvl2": null,
                  "lvl3": null,
                  "lvl4": null,
                  "lvl5": null,
                  "lvl6": null
                }
              },
              "highlights": [],
              "text_match": 1157451471441100800,
              "text_match_info": {
                "best_field_score": "2211897868288",
                "best_field_weight": 15,
                "fields_matched": 1,
                "score": "1157451471441100921",
                "tokens_matched": 2
              }
            }
          ]
        },
        {
          "group_key": [
            ""
          ],
          "hits": [
            {
...

06:49
Abhishek
06:49 PM
result
Image 1 for result
06:50
Abhishek
06:50 PM
question - If the result json has &lt;mark&gt;Audit&lt;/mark&gt; &lt;mark&gt;Trail&lt;/mark&gt; in the first group hites and then Your Clerky Account: &lt;mark&gt;Audit&lt;/mark&gt; &lt;mark&gt;Trail&lt;/mark&gt;s in the second group hit, shouldn't that be the 2nd result?
06:52
Abhishek
06:52 PM
the ordering is correct on the search result page though. I need the results to be shown in the same order in the popup as well.
Image 1 for the ordering is correct on the search result page though. I need the results to be shown in the same order in the popup as well.
06:53
Abhishek
06:53 PM
also, this is probably a bug but if the result matches against a heirarcy, no highlight text is shown in the popup. See last result in this popup.
Image 1 for also, this is probably a bug but if the result matches against a heirarcy, no highlight text is shown in the popup. See last result in this popup.
06:54
Abhishek
06:54 PM
here's the json result for the above -
            {
              "document": {
                "anchor": "audit-trail",
                "hierarchy": {
                  "lvl0": "Audit Trail ​",
                  "lvl1": null,
                  "lvl2": null,
                  "lvl3": null,
                  "lvl4": null,
                  "lvl5": null,
                  "lvl6": null
                },
                "hierarchy.lvl0": "Audit Trail ​",
                "id": "12",
                "type": "lvl0",
                "url": ""
              },
              "highlight": {
                "hierarchy": {
                  "lvl0": "Audit Trail ​",
                  "lvl1": null,
                  "lvl2": null,
                  "lvl3": null,
                  "lvl4": null,
                  "lvl5": null,
                  "lvl6": null
                }
              },
              "highlights": [],
              "text_match": 1157451471441100800,
              "text_match_info": {
                "best_field_score": "2211897868288",
                "best_field_weight": 15,
                "fields_matched": 1,
                "score": "1157451471441100921",
                "tokens_matched": 2
              }
            }
Mar 04, 2023 (7 months ago)
Abhishek
Photo of md5-39b08f19a4a6e14122188814743e5c3e
Abhishek
07:59 AM
ping Jason I'm mainly looking for a fix for my last two comments here - https://typesense-community.slack.com/archives/C01P749MET0/p1677869631345769?thread_ts=1677869266.139009&amp;cid=C01P749MET0
Could you confirm if this is a bug and possible fixes.
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
08:03 PM
The docsearch modal library groups results visually in a particular opinionated way… whereas the search results page is built by docusaurus, which follows a different approach, which is why they look different.
08:04
Jason
08:04 PM
If you look at the search queries generated when you type in the same query in the modal vs the search results page, you’ll see the exact differences in the query structure
08:05
Jason
08:05 PM
Could you open a GitHub issue for that blank highlight issue?
Mar 05, 2023 (7 months ago)
Mar 06, 2023 (7 months ago)
Abhishek
Photo of md5-39b08f19a4a6e14122188814743e5c3e
Abhishek
09:06 AM