Skip to content

Commit

Permalink
Update record-extractor.md
Browse files Browse the repository at this point in the history
updating docs on the record extractor
  • Loading branch information
randombeeper authored Jul 12, 2024
1 parent 4aa0c2c commit 5142612
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/website/docs/record-extractor.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,19 @@ You can now use them to [filter your search in the frontend][16]

### Boost search results with `pageRank`

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:
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.

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.

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.

```js
{
indexName: "YOUR_INDEX_NAME",
pathsToMatch: ["https://YOUR_WEBSITE_URL/api/**"],
recordExtractor: ({ $, helpers }) => {
recordExtractor: ({ $, helpers, url }) => {
const isDocPage = /\/[\w-]+\/docs\//.test(url.pathname);
const isBlogPage = /\/[\w-]+\/blog\//.test(url.pathname);
return helpers.docsearch({
recordProps: {
lvl0: {
Expand All @@ -194,7 +200,7 @@ This parameter allow you to boost records built from the current `pathsToMatch`.
lvl4: "article h5",
lvl5: "article h6",
content: "article p, article li",
pageRank: 30,
pageRank: isDocPage ? "-2000" : isBlogPage ? "-1000" : "0",
},
});
},
Expand Down

0 comments on commit 5142612

Please sign in to comment.