Logo

First steps

  • Read the Docs tutorial
  • Getting Started with Sphinx
  • Getting Started with MkDocs
  • Importing Your Documentation
  • Read the Docs features
  • Choosing Between Our Two Platforms
  • Glossary

Feature Overview

  • Configuration File
  • VCS Integrations
  • Custom Domains and White Labeling
  • Versioned Documentation
  • Downloadable Documentation
  • Documentation Hosting Features
  • Server Side Search
    • Search features
    • Search Analytics
    • API
      • Authentication and authorization
  • Traffic Analytics
  • Preview Documentation from Pull Requests
  • Build Notifications and Webhooks
  • Security Log
  • Connecting Your VCS Account
  • Build process
  • Build customization
  • Environment Variables
  • Badges
  • Site Support
  • Frequently Asked Questions

How-to Guides

  • Guides for documentation authors
  • Guides for project administrators
  • Guides for developers and designers

Advanced features

  • Subprojects
  • Single Version Documentation
  • Feature Flags
  • Localization of Documentation
  • User-defined Redirects
  • Automatic Redirects
  • Automation Rules
  • Public API

Read the Docs for Business

  • Read the Docs for Business
  • Organizations
  • Project Privacy Level
  • Sharing
  • Single Sign-On

About Read the Docs

  • Security
  • DMCA Takedown Policy
  • Policy for Abandoned Projects
  • Changelog
  • About Read the Docs
  • Read the Docs Team
  • Read the Docs Open Source Philosophy
  • The Story of Read the Docs
  • Advertising
  • Sponsors of Read the Docs
  • Legal Documents and Policies
  • Developer Documentation
  • Google Summer of Code
Read the Docs user documentation
  • »
  • Server Side Search
  • Edit on GitHub

Server Side Search¶

Read the Docs provides full-text search across all of the pages of all projects, this is powered by Elasticsearch. You can search all projects at https://readthedocs.org/search/, or search only on your project from the Search tab of your project.

We override the default search engine of your project with our search engine to provide you better results within your project. We fallback to the built-in search engine from your project if our search engine doesn’t return any results, just in case we missed something 😄

Search features¶

We offer a number of benefits compared to other documentation hosts:

Search across subprojects

Subprojects allow you to host multiple discrete projects on a single domain. Every subproject hosted on that same domain is included in the search results of the main project.

Search results land on the exact content you were looking for

We index every heading in the document, allowing you to get search results exactly to the content that you are searching for. Try this out by searching for “full-text search”.

Full control over which results should be listed first

Set a custom rank per page, allowing you to deprecate content, and always show relevant content to your users first. See search.ranking.

Search across projects you have access to (Read the Docs for Business)

This allows you to search across all the projects you access to in your Dashboard. Don’t remember where you found that document the other day? No problem, you can search across them all.

Special query syntax for more specific results.

We support a full range of search queries. You can see some examples in our Search query syntax guide.

Configurable.

Tweak search results according to your needs using a configuration file.

Search Analytics¶

Know what your users are looking for in your docs. To see a list of the top queries and an overview from the last month, go to the Admin tab of your project, and then click on Search Analytics.

Search analytics demo

Search analytics demo¶

API¶

If you are using Read the Docs for Business you will need to replace https://readthedocs.org/ with https://readthedocs.com/ in all the URLs used in the following examples. Check Authentication and authorization if you are using private versions.

Warning

This API isn’t stable yet, some small things may change in the future.

GET /api/v2/search/¶

Return a list of search results for a project, including results from its Subprojects. Results are divided into sections with highlights of the matching term.

Query Parameters
  • q – Search query

  • project – Project slug

  • version – Version slug

  • page – Jump to a specific page

  • page_size – Limits the results per page, default is 50

Response JSON Object
  • type (string) – The type of the result, currently page is the only type.

  • project (string) – The project slug

  • project_alias (string) – Alias of the project if it’s a subproject.

  • version (string) – The version slug

  • title (string) – The title of the page

  • domain (string) – Canonical domain of the resulting page

  • path (string) – Path to the resulting page

  • highlights (object) – An object containing a list of substrings with matching terms. Note that the text is HTML escaped with the matching terms inside a <span> tag.

  • blocks (object) –

    A list of block objects containing search results from the page. Currently, there are two types of blocks:

    • section: A page section with a linkable anchor (id attribute).

    • domain: A Sphinx domain with a linkable anchor (id attribute).

Example request:

$ curl "https://readthedocs.org/api/v2/search/?project=docs&version=latest&q=server%20side%20search"
import requests
URL = 'https://readthedocs.org/api/v2/search/'
params = {
   'q': 'server side search',
   'project': 'docs',
   'version': 'latest',
}
response = requests.get(URL, params=params)
print(response.json())

Example response:

{
    "count": 41,
    "next": "https://readthedocs.org/api/v2/search/?page=2&project=read-the-docs&q=server+side+search&version=latest",
    "previous": null,
    "results": [
        {
            "type": "page",
            "project": "docs",
            "project_alias": null,
            "version": "latest",
            "title": "Server Side Search",
            "domain": "https://docs.readthedocs.io",
            "path": "/en/latest/server-side-search.html",
            "highlights": {
                "title": [
                    "<span>Server</span> <span>Side</span> <span>Search</span>"
                ]
            },
            "blocks": [
               {
                  "type": "section",
                  "id": "server-side-search",
                  "title": "Server Side Search",
                  "content": "Read the Docs provides full-text search across all of the pages of all projects, this is powered by Elasticsearch.",
                  "highlights": {
                     "title": [
                        "<span>Server</span> <span>Side</span> <span>Search</span>"
                     ],
                     "content": [
                        "You can <span>search</span> all projects at https:&#x2F;&#x2F;readthedocs.org&#x2F;<span>search</span>&#x2F"
                     ]
                  }
               },
               {
                  "type": "domain",
                  "role": "http:get",
                  "name": "/_/api/v2/search/",
                  "id": "get--_-api-v2-search-",
                  "content": "Retrieve search results for docs",
                  "highlights": {
                     "name": [""],
                     "content": ["Retrieve <span>search</span> results for docs"]
                  }
               }
            ]
        },
    ]
}

Authentication and authorization¶

If you are using private versions, users will only be allowed to search projects they have permissions over. Authentication and authorization is done using the current session, or any of the valid sharing methods.

To be able to use the user’s current session you need to use the API from the domain where your docs are being served (<you-docs-domain>/_/api/v2/search/). This is https://docs.readthedocs-hosted.com/_/api/v2/search/ for the https://docs.readthedocs-hosted.com/ project, for example.

Previous Next

© Copyright 2010, Read the Docs, Inc & contributors. Revision 7e9183f2.

Built with Sphinx using a theme provided by Read the Docs.
Read the Docs v: stable
Versions
latest
stable
Downloads
pdf
html
epub
On Read the Docs
Project Home
Builds