Searching with Read the Docs
Read the Docs uses Elasticsearch to provide a better search experience. This guide is intended to show that how to add "search as you type" feature to your documentation, how to use advanced query syntax to get more accurate results and many other search features that Read the Docs supports with example searches.
You can find information on the search architecture and how we index document on our :doc:`Search <../development/search>` docs.
Table of contents
- Improvements over Sphinx search
- Search features for project admins
- Search features for readers
Improvements over Sphinx search
Sphinx is designed to create a self-contained webpage and all search indexing is done when the documentation is built. As a result, it would be impossible for Sphinx to add features like searching translations or subprojects or having analytics on common searches. Read the Docs supports a powerful documentation search unlike Sphinx which only have a basic search support.
Features of Read the Docs documentation search are:
- Search as you type feature supported.
- Search analytics.
- Search across multiple projects.
- Search inside subprojects.
- Advanced query syntax.
- Improved search result order.
- Public search API (documentation pending).
- Case insensitive search.
- Results from sections of the documentation.
- Code search.
Search features for project admins
Enable "search as you type" in your documentation
readthedocs-sphinx-search is a Sphinx extension which integrates your documentation more closely with Read the Docs' search implementation. It adds a clean and minimal full page search UI which supports search as you type feature.
To get a glimpse of it, you can press :guilabel:`/` (forward slash) and start typing or just visit these URLs:
Search queries are recorded and are stored in database to provide valuable analytics to the project admins. These analytics makes it easy to know what your users are looking for in your documentation. You can see these analytics in your project admin dashboard.
Currently, this feature is in beta state and is available under a :ref:`feature flag <guides/feature-flags:Available Flags>`. We plan to make this available for everyone soon. If you want to test this feature out and help giving us feedback, please contact us via GitHub issues.
Search features for readers
Search across all projects
Our main site search supports searching for projects and searching across all projects. You can also use it to select the specific project and version to narrow down the search results.
Search inside subprojects
We allow projects to configured as subprojects of another project. You can read more about this in our :doc:`Subprojects <../subprojects>` documentation.
If a search is made in a project which have one or more subprojects under it, the search results then also includes the results from subprojects because they share a search index with their parent and sibling projects. For example: Kombu is one of the subprojects of Celery, so if you search in Celery docs, then the results from Kombu will also be there. Example: https://docs.celeryproject.org/en/master/search.html?q=utilities&check_keywords=yes&area=default
Search query syntax
Exact phrase search
If a query is wrapped in
then only those results where the phrase is exactly matched will be returned.
Exact phrase search with slop value
~N after a phrase signifies slop amount.
It can be used to match words which are near one another.
* at the end of any term signifies a prefix query.
It returns the results containg the words with specific prefix.
~N after a word signifies edit distance (fuzziness).
This type of query is helpful when spelling of the actual keyword is unsure.
It returns results that contain terms similar to the search term,
as measured by a Levenshtein edit distance.
Using the search query syntax to build complex queries
The search query syntaxes described in the previous section can be used with one another to build complex queries.