Skip to content

[Feature Request]: Fusion search engine for monolith rspress projects #1297

Open
@zoolsher

Description

@zoolsher

What problem does this feature solve?

In complex and large-scale projects, the current search functionality lacks classification capabilities, making it difficult for users to efficiently find the information they need. As the volume of project data increases, unclassified search results can get lost in the vast sea of information, leading to imprecise search results and decreased user productivity. By providing a search feature with classification capabilities, users can more accurately and quickly find the information they need based on specific categories. This makes the search process more purposeful and efficient, thereby improving user experience and work efficiency.

What does the proposed API look like?

add category to meta

step 1. Configure all available categories in rspress.config.js

export default {
  search: {
    categories: ['css', 'html', 'foo', 'bar']
  }
}

step 2. Declare a document’s category

---
category: ['css', 'html']
category: 'css'
---

The markdown content

UI for search with category

Search With Category

UI for search without category

Search Without Category

Q&A

Can document writers add any category they wish?

No.

The categories are defined by the search engine, so they must be a fixed set controlled by the project configuration.

What if a markdown file does not specify a category?

It will automatically extend from its parent folder. The root folder will have a default category, which is the first one in the categories set by default. You can also specify this with the following configuration:

export default {
  search: {
    categories: ['css', 'html', 'foo', 'bar'],
    defaultCategory: 'foo', // defaults to 'css'
  }
}

Support for custom sources?

If a developer wants to add custom categories such as ai, discord qa channel, or github issues, where the name, content, and display are all customized, they can use the category plugin feature. Here’s how:

export default {
  search: {
    categories: ['css', 'html', 'foo', 'bar'],
    categoryPlugins: [{ 
      name: "baz",
      search: (context) => {
        // Code to execute when a user searches within this category
        return SomeReactComponent;
      }
    }],
  }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions