-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Search: custom search page ranking #7237
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
Merged
+570
−34
Merged
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
985e3bd
Add search page rankings
stsewd c836a40
Update docs
stsewd c38df09
Fix tests
stsewd fa0d102
Fix linter
stsewd 54b4f54
Update docs
stsewd 83157fb
Pass dict, config object isn't serializable
stsewd 8c3434b
Do ranking at query time
stsewd d0d5785
Update docs
stsewd 3ad8d18
Linter
stsewd 4384242
Add tip
stsewd 596ff77
Add comment
stsewd 8e3bdef
TODO about alternative precedence
stsewd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ Below is an example YAML file which shows the most common configuration options: | |
# configuration: mkdocs.yml | ||
|
||
# Optionally build your docs in additional formats such as PDF | ||
formats: | ||
formats: | ||
|
||
# Optionally set the version of Python and requirements required to build your docs | ||
|
@@ -74,11 +74,15 @@ Example: | |
|
||
.. code-block:: yaml | ||
|
||
version: 2 | ||
|
||
# Default | ||
formats: [] | ||
|
||
.. code-block:: yaml | ||
|
||
version: 2 | ||
|
||
# Build PDF & ePub | ||
formats: | ||
- epub | ||
|
@@ -90,6 +94,8 @@ Example: | |
|
||
.. code-block:: yaml | ||
|
||
version: 2 | ||
|
||
# Build all formats | ||
formats: all | ||
|
||
|
@@ -104,6 +110,8 @@ Configuration of the Python environment to be used. | |
|
||
.. code-block:: yaml | ||
|
||
version: 2 | ||
|
||
python: | ||
version: 3.7 | ||
install: | ||
|
@@ -153,6 +161,8 @@ Example: | |
|
||
.. code-block:: yaml | ||
|
||
version: 2 | ||
|
||
python: | ||
version: 3.7 | ||
install: | ||
|
@@ -199,6 +209,8 @@ Example: | |
|
||
.. code-block:: yaml | ||
|
||
version: 2 | ||
|
||
python: | ||
version: 3.7 | ||
install: | ||
|
@@ -242,6 +254,8 @@ Configuration for Conda support. | |
|
||
.. code-block:: yaml | ||
|
||
version: 2 | ||
|
||
conda: | ||
environment: environment.yml | ||
|
||
|
@@ -260,6 +274,8 @@ Configuration for the documentation build process. | |
|
||
.. code-block:: yaml | ||
|
||
version: 2 | ||
|
||
build: | ||
image: latest | ||
|
||
|
@@ -290,6 +306,8 @@ Configuration for Sphinx documentation | |
|
||
.. code-block:: yaml | ||
|
||
version: 2 | ||
|
||
sphinx: | ||
builder: html | ||
configuration: conf.py | ||
|
@@ -335,6 +353,8 @@ Configuration for Mkdocs documentation. | |
|
||
.. code-block:: yaml | ||
|
||
version: 2 | ||
|
||
mkdocs: | ||
configuration: mkdocs.yml | ||
fail_on_warning: false | ||
|
@@ -374,6 +394,8 @@ VCS submodules configuration. | |
|
||
.. code-block:: yaml | ||
|
||
version: 2 | ||
|
||
submodules: | ||
include: | ||
- one | ||
|
@@ -394,6 +416,8 @@ List of submodules to be included. | |
|
||
.. code-block:: yaml | ||
|
||
version: 2 | ||
|
||
submodules: | ||
include: all | ||
|
||
|
@@ -412,6 +436,8 @@ List of submodules to be excluded. | |
|
||
.. code-block:: yaml | ||
|
||
version: 2 | ||
|
||
submodules: | ||
exclude: all | ||
|
||
|
@@ -427,6 +453,65 @@ Do a recursive clone of the submodules. | |
|
||
This is ignored if there aren't submodules to clone. | ||
|
||
search | ||
~~~~~~ | ||
|
||
Settings for more control over :doc:`/server-side-search`. | ||
|
||
.. code-block:: yaml | ||
|
||
version: 2 | ||
|
||
search: | ||
ranking: | ||
api/v1/*: -1 | ||
api/v2/*: 4 | ||
|
||
search.ranking | ||
`````````````` | ||
|
||
Set a custom search rank over pages matching a pattern. | ||
|
||
:Type: ``map`` of patterns to ranks | ||
:Default: ``{}`` | ||
|
||
Patterns are matched against the final html pages produced by the build | ||
(you should try to match `index.html`, not `docs/index.rst`). | ||
Patterns can include some special characters: | ||
|
||
- ``*`` matches everything | ||
- ``?`` matches any single character | ||
- ``[seq]`` matches any character in ``seq`` | ||
|
||
The rank can be an integer number between -10 and 10 (inclusive). | ||
Pages with a rank closer to -10 will appear further down the list of results, | ||
and pages with a rank closer to 10 will appear higher in the list of results. | ||
Note that 0 means *normal rank*, not *no rank*. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point 👍 |
||
|
||
.. code-block:: yaml | ||
|
||
version: 2 | ||
|
||
search: | ||
ranking: | ||
# Match a single file | ||
tutorial.hml: 2 | ||
|
||
# Match all files under the api/v1 directory | ||
api/v1/*: -5 | ||
|
||
# Match all files that end with tutorial.html | ||
*/tutorial.html: 3 | ||
|
||
.. note:: | ||
|
||
The final rank will be the last pattern to match the page. | ||
|
||
.. tip:: | ||
|
||
Is better to decrease the rank of pages you want to deprecate, | ||
rather than increasing the rank of the other pages. | ||
|
||
Schema | ||
------ | ||
|
||
|
@@ -468,6 +553,7 @@ New settings | |
- :ref:`config-file/v2:mkdocs` | ||
- :ref:`config-file/v2:submodules` | ||
- :ref:`config-file/v2:python.install` | ||
- :ref:`config-file/v2:search` | ||
|
||
Migrating from the web interface | ||
-------------------------------- | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can mark this option as experimental if we want to try it first, but we can make changes without re-indexing, so we are safe to do some tuning after if needed.