1
0
Fork 0
docsearch/docs/source/documentation/4-docsearch-FAQ/1-customize-configuration-file.html.md.erb
Sylvain Pace 9388d9434f
Enhancing DocSearch FAQ (#388)
* enhancing DocSearch FAQ

* fixing issues

* fixing issues
2018-07-30 13:44:42 +02:00

79 lines
No EOL
2.7 KiB
Text

---
title: Customize my DocSearch
---
## What content do we recommend to index?
### Code blocks
We **do not recommend** indexing **code tags** since code blocks are most likely
very similar and redundant from one page to another.
You can exclude code blocks by adding their matching selectors to `selectors_exclude`.
A good practice would be to emphasize the meaningful underlying part of it
thanks to a dedicated class, which you will want to add to the `text` selector
in your configuration file.
For example, in this code snippet, you can exclude the code but the parameters of the function:
```
<code>
function(<toIndex>something useful to search for</toIndex>)
...
</code>
```
### Table of contents
The elements of the table of contents only *target* but do not provide content.
They are merely a step on the way to reaching relevant content. As a result, they are
almost always in a different place from the payload. This is why we consider the
table of contents an obstacle for DocSearch to find the coveted information.
We therefore **do not recommend** indexing the elements of the table of contents; their matching
selectors should be added to `selectors_exclude`.
## How are my DocSearch records ranked?
DocSearch empowers the Algolia ranking strategy. The formula is completely
based on [the tie-breaking approach](https://www.algolia.com/doc/guides/ranking/ranking-formula/#tie-breaking-approach).
The special feature of DocSearch's ranking resides in [the custom ranking](https://www.algolia.com/doc/guides/ranking/custom-ranking/):
We have defined 3 main weight indicators for every record. These values are
ordered by importance following the tie-breaking approach:
1. `page_rank`: this value, equal to `0` by default, can be set from the
`start_urls` object. It can be customized in order to boost or restrain some
records depending on **their webpage's URL**. It will need to match a **specific
regular expression pattern**.
**Example:**
```json
{
"index_name": "example",
"start_urls": [
{
"url": "http://example.com/docs/api/v1\\.[0-9]",
"page_rank": 1
}
]
}
```
2. `level`: this value depends on the `level` of the record. A record's level is
its **deepest level attribute not null**. `text` records have a weight of 0.
3. `position`: This value is the position of the matching element within every
picked up element along the original HTML flow. The **sooner** the record appears,
the **higher** it will be ranked.
You can override the way these elements are impacting the search thanks to `custom_settings`.
**Example:**
```json
"custom_settings": {
"customRanking": [
"asc(weight.position)",
"desc(weight.page_rank)",
"desc(weight.level)"
]
}
```