Skip to content

Commit 5142612

Browse files
authored
Update record-extractor.md
updating docs on the record extractor
1 parent 4aa0c2c commit 5142612

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

packages/website/docs/record-extractor.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,19 @@ You can now use them to [filter your search in the frontend][16]
176176

177177
### Boost search results with `pageRank`
178178

179-
This parameter allow you to boost records built from the current `pathsToMatch`. Pages with highest [`pageRank`](#pagerank) will be returned before pages with a lower [`pageRank`](#pagerank). Note that you can pass any numeric value **as a string**, including negative values:
179+
This parameter allows you to boost records using a custom ranking attribute built from the current `pathsToMatch`. Pages with highest [`pageRank`](#pagerank) will be returned before pages with a lower [`pageRank`](#pagerank). The default value is 0 and you can pass any numeric value **as a string**, including negative values.
180+
181+
Search results are sorted by weight (desc), so you can have both boosted and non boosted results. The weight of each result will be computed for a given query based on multiple factors: match level, position, etc. and the pageRank value will be added to this final weight. The pageRank on its own may not be enough to influence the results of your query depending on how your [overall ranking is set up](https://www.algolia.com/doc/guides/managing-results/relevance-overview/in-depth/ranking-criteria/). If changing the pageRank value doesn't influence your search results enough, even with large values, move weight.pageRank higher in the Ranking and Sorting page for your index.
182+
183+
You can view the computed weight directly from the Algolia dashboard (dashboard.algolia.com->search->perform a search->mouse hover over the "ranking criteria" icon bottom right of each record). That will give you an idea of what pageRank value is acceptable for your case.
180184

181185
```js
182186
{
183187
indexName: "YOUR_INDEX_NAME",
184188
pathsToMatch: ["https://YOUR_WEBSITE_URL/api/**"],
185-
recordExtractor: ({ $, helpers }) => {
189+
recordExtractor: ({ $, helpers, url }) => {
190+
const isDocPage = /\/[\w-]+\/docs\//.test(url.pathname);
191+
const isBlogPage = /\/[\w-]+\/blog\//.test(url.pathname);
186192
return helpers.docsearch({
187193
recordProps: {
188194
lvl0: {
@@ -194,7 +200,7 @@ This parameter allow you to boost records built from the current `pathsToMatch`.
194200
lvl4: "article h5",
195201
lvl5: "article h6",
196202
content: "article p, article li",
197-
pageRank: 30,
203+
pageRank: isDocPage ? "-2000" : isBlogPage ? "-1000" : "0",
198204
},
199205
});
200206
},

0 commit comments

Comments
 (0)