|
1 | 1 | --- |
2 | 2 | title: Search configuration |
3 | | -description: Configure search for your Fern docs using Algolia DocSearch. Filter by product, version, content type, API type, HTTP method, status code, and availability. |
| 3 | +description: Configure search for your Fern docs using Algolia DocSearch. Learn how search filters work, how results are ranked, and how to integrate with Algolia. |
4 | 4 | --- |
5 | 5 |
|
6 | 6 | <Markdown src="/snippets/agent-directive.mdx"/> |
@@ -40,6 +40,49 @@ If you're using [Ask Fern](/learn/docs/ai-features/ask-fern/overview) (AI search |
40 | 40 | Pages with the `nofollow` or `noindex` [frontmatter](/learn/docs/configuration/page-level-settings#indexing-properties) are excluded from the Algolia DocSearch index and won't appear in search results. |
41 | 41 | </Note> |
42 | 42 |
|
| 43 | +## How results are ranked |
| 44 | + |
| 45 | +Fern configures Algolia's ranking to prioritize matches in high-signal attributes like titles and keywords over body text, then applies tiebreakers for recency, version, and page position. |
| 46 | + |
| 47 | +<AccordionGroup> |
| 48 | + <Accordion title="Attribute weighting"> |
| 49 | + Algolia ranks results based on which attributes contain the matching text. Attributes listed earlier are weighted higher than those listed later. Fern configures the following searchable attributes, in order of priority: |
| 50 | + |
| 51 | + | Priority | Attribute | Description | |
| 52 | + | --- | --- | --- | |
| 53 | + | 1 | Keywords | [Keywords](/learn/docs/configuration/page-level-settings#document-properties) set in the page's frontmatter. Use these to surface a page for queries without changing its content. | |
| 54 | + | 2 | Page title | The [title](/learn/docs/configuration/page-level-settings#title) set in frontmatter or `docs.yml` | |
| 55 | + | 3 | Heading hierarchy (h1–h6) | [Headings](/learn/docs/writing-content/markdown-basics#page-header) within the page, from h1 (highest) to h6 (lowest) | |
| 56 | + | 4 | Endpoint path | The API endpoint path (e.g., `/plants/{plantId}`) | |
| 57 | + | 5 | Endpoint path alternates | Alternative representations of the endpoint path | |
| 58 | + | 6 | Parameter name | Names of API parameters | |
| 59 | + | 7 | Metadata attributes | Availability, API type, HTTP method, content type, response type, status code, and parameter type | |
| 60 | + | 8 | Breadcrumb | The navigation breadcrumb trail for the page | |
| 61 | + | 9 | Description | The page's [meta description](/learn/docs/configuration/page-level-settings#meta-description) | |
| 62 | + | 10 | Body content | The full body text of the page | |
| 63 | + | 11 | Code snippets | [Code blocks](/learn/docs/writing-content/components/code-blocks) embedded in the page | |
| 64 | + |
| 65 | + All attributes use `unordered` matching, meaning that the position of the query terms within an attribute doesn't affect ranking. For example, a match at the end of a page title ranks the same as a match at the beginning. |
| 66 | + </Accordion> |
| 67 | + <Accordion title="Tiebreaking"> |
| 68 | + When multiple results have the same text relevance score, Fern applies custom ranking rules as tiebreakers: |
| 69 | + |
| 70 | + 1. **Date (descending):** Newer content ranks higher. This primarily affects changelog entries, which carry a timestamp. |
| 71 | + 2. **Version index (ascending):** Content from the default version ranks above content from older versions. This prevents duplicate results across versioned docs. |
| 72 | + 3. **Page position (ascending):** Content closer to the top of a page ranks above content further down. For example, a heading match near the top of a page outranks a section match further down on the same page. |
| 73 | + |
| 74 | + Additionally, Fern deduplicates results by canonical pathname, so each page appears at most once in the results. The version index and page position tiebreakers determine which record represents the page when duplicates exist. |
| 75 | + </Accordion> |
| 76 | + <Accordion title="Page hierarchy"> |
| 77 | + The navigation hierarchy of your documentation doesn't directly affect search ranking. A nested page ranks the same as a top-level page for text relevance purposes. However, within a single page, heading depth does matter: matches in h1 headings rank above h2, h2 above h3, and so on. The heading hierarchy is stored per record, so Algolia can distinguish between a match in a top-level section and one in a subsection. |
| 78 | + </Accordion> |
| 79 | + <Accordion title="Empty result handling"> |
| 80 | + If a query returns no results, Algolia progressively removes common documentation terms to broaden the search. The following words are treated as optional when no exact matches are found: `endpoint`, `api`, `guide`, `documentation`, `doc`, `parameter`, `webhook`, `websocket`, `http`, `code`, and `snippet`. |
| 81 | + |
| 82 | + For example, a search for `webhook endpoint` that returns no results is retried as `webhook` and `endpoint` individually. |
| 83 | + </Accordion> |
| 84 | +</AccordionGroup> |
| 85 | + |
43 | 86 | ## Integrating with Algolia |
44 | 87 |
|
45 | 88 | If you need to integrate Fern's documentation search into your own application or dashboard, you can request Algolia credentials directly from the Fern team. These credentials will allow you to query the same search index that powers your documentation site's search functionality. |
|
0 commit comments