Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: document recordVersion #1380

Merged
merged 2 commits into from
Apr 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions packages/website/docs/api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,17 @@ const translations: DocSearchTranslations = {

> `type: ({ query: string }) => string` | **optional**

> example: ({ query }) => `https://github.com/algolia/docsearch/issues/new?title=${query}`

Function to return the URL of your documentation repository.

```js
docsearch({
// ...
getMissingResultsUrl({ query }) {
return `https://github.com/algolia/docsearch/issues/new?title=${query}`;
},
});
```

When provided, an informative message wrapped with your link will be displayed on no results searches. The default text can be changed using the [translations](#translations) property.

<div className="uil-ta-center">
Expand Down Expand Up @@ -375,10 +382,17 @@ const translations: DocSearchTranslations = {

> `type: ({ query: string }) => string` | **optional**

> example: ({ query }) => `https://github.com/algolia/docsearch/issues/new?title=${query}`

Function to return the URL of your documentation repository.

```jsx
<DocSearch
// ...
getMissingResultsUrl={({ query }) => {
return `https://github.com/algolia/docsearch/issues/new?title=${query}`;
}}
/>
```

When provided, an informative message wrapped with your link will be displayed on no results searches. The default text can be changed using the [translations](#translations) property.

<div className="uil-ta-center">
Expand Down
33 changes: 32 additions & 1 deletion packages/website/docs/record-extractor.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ This parameter allow you to boost records built from the current `pathsToMatch`.

### Reduce the number records

If you encounter the `Extractors returned too many records` error when your page outputs more than 750 records, you can use the `aggregateContent` option to reduce the number of records at the `content` level.
If you encounter the `Extractors returned too many records` error when your page outputs more than 750 records. The [`aggregateContent`](#aggregatecontent) option helps you reducing the number of records at the `content` level of the extractor.

```js
{
Expand All @@ -226,6 +226,31 @@ If you encounter the `Extractors returned too many records` error when your page
},
```

### Reduce the record size

If you encounter the `Records extracted are too big` error when crawling your website, it's mostly because there was too many informations in your records, or that your page is too big. The [`recordVersion`](#recordversion) option helps you reducing the records size by removing informations that are only used with [DocSearch v2](/docs/legacy/dropdown).

```js
{
indexName: "YOUR_INDEX_NAME",
pathsToMatch: ["https://YOUR_WEBSITE_URL/api/**"],
recordExtractor: ({ $, helpers }) => {
return helpers.docsearch({
recordProps: {
lvl0: "header h1",
lvl1: "article h2",
lvl2: "article h3",
lvl3: "article h4",
lvl4: "article h5",
lvl5: "article h6",
content: "article p, article li",
},
recordVersion: "v3",
});
},
},
```

## `recordProps` API Reference

### `lvl0`
Expand Down Expand Up @@ -278,6 +303,12 @@ Custom variables are used to [`filter your search`](/docs/DocSearch-v3#filtering

[This options](#reduce-the-number-records) groups the Algolia records created at the `content` level of the selector into a single record for its matching heading.

### `recordVersion`

> `type: 'v3' | 'v2'` | default: `v2` | **optional**

[This options](#reduce-the-record-size) remove content from the Algolia records that are only used for [DocSearch v2](/docs/legacy/dropdown). If you are using [the latest version of DocSearch](/docs/DocSearch-v3), you can [set it to `v3`](#reduce-the-record-size).

### `indexHeadings`

> `type: boolean | { from: number, to: number }` | default: `true` | **optional**
Expand Down