Skip to content

Search Relevance Tweaks #1929

Closed
Closed
@shmax

Description

@shmax

Search Terms

Search, Relevance, Lunr

Problem

My colleagues and I have spent the last few weeks rigging up TypeDoc on our TypeScript library. For the most part it works beautifully and we're astonished how well this project works out of the box, but we've been having some trouble with a few quirks in the search feature:

  • exact matches don't seem to get a boost in relevance. We have a class called "Button", but when we search for "button", the main result we're interested in gets muscled down to the 53rd slot by other minor results that have "button" in their name (eg. "Foo.primaryButton"),
  • there's no way to adjust the number of search results, and no "View all" option
  • classes don't seem to get a boost over props and other minor features
  • there's no way to boost on things like categories

I understand that not everyone wants search to work the same way, so I thought this might be a good candidate for a plugin, but once I looked into it I realized that plugins seem to have more to do with reflection than runtime adjustments like this.

So, before we dive in and start preparing a PR, I thought I'd see if you folks can provide any insight or background.

Suggested Solution

Off the top of my head, I would like to see some kind of search configuration on typedoc.json. Maybe something like this:

{
  ...
  "search": {
    "maxResults": 10,
    "weights": {
     "isClass": 1.1,
     "exactMatch": 2.1,
     "byCategory": {
        "component": 3.4,
        "coreComponent": 4
      }
    }
  }
}

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions