Skip to content

Commit f329915

Browse files
committed
add search guide
1 parent 3c04a96 commit f329915

File tree

3 files changed

+191
-0
lines changed

3 files changed

+191
-0
lines changed
Loading

docs/guides/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ These guides will help you customize or tune aspects of the Read the Docs build
4040
environment-variables
4141
feature-flags
4242
google-analytics
43+
searching-with-readthedocs
4344
sitemaps
4445
specifying-dependencies
4546
wipe-environment
Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
Searching with Read the Docs
2+
============================
3+
4+
.. meta::
5+
:description lang=en:
6+
Guide to use the powerful documentation search by Read the Docs to its full extent.
7+
8+
9+
This guide is intended to show that how to use the powerful search provided by Read the Docs.
10+
It is being powered by `Elasticsearch`_.
11+
You can find more information on the search architecture and how we index document on our
12+
:doc:`Search <../development/search>` docs.
13+
14+
15+
.. contents:: Table of contents
16+
:local:
17+
:backlinks: none
18+
:depth: 3
19+
20+
21+
Why "Just" Sphinx Search Is Not Enough?
22+
---------------------------------------
23+
24+
Sphinx already have built in search functionality,
25+
but it only supports a basic search across a single documentation.
26+
While Read the Docs supports a powerful documentation search.
27+
28+
Features of Read the Docs documentation search are:
29+
30+
- Search as you type feature supported.
31+
- Search across multiple projects.
32+
- Advanced query syntax.
33+
- Search inside subprojects.
34+
- Improved search result order.
35+
- Public Search API (Documentation pending).
36+
- Case insensitive search.
37+
- Results from sections of the documentation.
38+
- Code search.
39+
- Search analytics.
40+
41+
42+
Search Features for Project Admins
43+
----------------------------------
44+
45+
Enable "Search As You Type" In Your Documentation
46+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
47+
48+
`readthedocs-sphinx-search`_ can be used to add a clean and minimal full page search UI
49+
to your documentation which supports **search as you type** feature.
50+
51+
To get a glimpse of it, you can press :guilabel:`/` (forward slash) and start typing
52+
or just visit these URLs:
53+
54+
- https://docs.readthedocs.io/?rtd_search=contributing
55+
- https://docs.readthedocs.io/?rtd_search=api/v3/projects/
56+
57+
58+
Search Analytics
59+
~~~~~~~~~~~~~~~~
60+
61+
Search queries are recorded and are stored in database to provide valuable analytics to the project admins.
62+
These analytics makes it easy to know what your users are looking for in your documentation.
63+
You can see these analytics in your project admin dashboard.
64+
65+
.. note::
66+
67+
Currently, this feature is in beta state and is available under a
68+
:ref:`feature flag <guides/feature-flags:Available Flags>`.
69+
We plan to make this available for everyone soon.
70+
If you want to test this feature out and help giving us feedback,
71+
please contact us via `GitHub issues`_.
72+
73+
.. figure:: /_static/images/guides/search-analytics-demo.png
74+
:width: 40%
75+
:align: center
76+
:alt: Search analytics in project admin dashboard
77+
78+
Search analytics demo
79+
80+
81+
Search Features For Readers
82+
---------------------------
83+
84+
Search Across All Projects
85+
~~~~~~~~~~~~~~~~~~~~~~~~~~
86+
87+
Our `main site search`_ supports searching for projects and
88+
searching across all projects.
89+
You can use it to select the specific project and version to narrow down the search results.
90+
91+
Example queries:
92+
93+
- https://readthedocs.org/search/?q=celery&type=project
94+
- https://readthedocs.org/search/?q=celery._state&type=file
95+
- https://readthedocs.org/search/?q=celery._state&type=file&project=celery
96+
- https://readthedocs.org/search/?q=celery._state&type=file&project=celery&version=master
97+
98+
99+
Search Inside Subprojects
100+
~~~~~~~~~~~~~~~~~~~~~~~~~
101+
102+
We allow projects to configured as subprojects of another project.
103+
You can read more about this in our :doc:`Subprojects <../subprojects>` documentation.
104+
105+
If a search is made in a project which have one or more subprojects under it,
106+
the search results then also includes the results from subprojects because
107+
they share a search index with their parent and sibling projects.
108+
For example: `Kombu`_ is one of the subprojects of `Celery`_,
109+
so if you search in Celery docs, then the results from Kombu will also be there.
110+
Example: https://docs.celeryproject.org/en/master/search.html?q=utilities&check_keywords=yes&area=default
111+
112+
113+
Search Query Syntax
114+
~~~~~~~~~~~~~~~~~~~
115+
116+
Read the Docs uses `Simple Query String`_ feature of `Elasticsearch`_,
117+
hence the search query can be made complex to get more accurate results.
118+
119+
Exact Phrase Search
120+
+++++++++++++++++++
121+
122+
If a query is wrapped in ``"``,
123+
then only those results where the phrase is exactly matched will be returned.
124+
125+
Example queries:
126+
127+
- https://docs.readthedocs.io/?rtd_search=%22custom%20css%22
128+
- https://docs.readthedocs.io/?rtd_search=%22adding%20a%20subproject%22
129+
- https://docs.readthedocs.io/?rtd_search=%22when%20a%20404%20is%20returned%22
130+
131+
Exact Phrase Search With Slop Value
132+
+++++++++++++++++++++++++++++++++++
133+
134+
``~N`` after a phrase signifies slop amount.
135+
It can be used to match words which are near one another.
136+
137+
Example queries:
138+
139+
- https://docs.readthedocs.io/?rtd_search=%22dashboard%20admin%22~2
140+
- https://docs.readthedocs.io/?rtd_search=%22single%20documentation%22~1
141+
- https://docs.readthedocs.io/?rtd_search=%22read%20the%20docs%20story%22~5
142+
143+
Prefix Query
144+
++++++++++++
145+
146+
``*`` at the end of any term signifies a prefix query.
147+
It returns the results containg the words with specific prefix.
148+
149+
Example queries:
150+
151+
- https://docs.readthedocs.io/?rtd_search=API%20v*
152+
- https://docs.readthedocs.io/?rtd_search=single%20v*%20doc*
153+
- https://docs.readthedocs.io/?rtd_search=build*%20and%20c*%20to%20doc*
154+
155+
Fuzzy Query
156+
+++++++++++
157+
158+
``~N`` after a word signifies edit distance (fuzziness).
159+
This type of query is helpful when spelling of the actual keyword is unsure.
160+
It returns results that contain terms similar to the search term,
161+
as measured by a `Levenshtein edit distance`_.
162+
163+
Example queries:
164+
165+
- https://docs.readthedocs.io/?rtd_search=reedthedcs~2
166+
- https://docs.readthedocs.io/?rtd_search=authentation~3
167+
- https://docs.readthedocs.io/?rtd_search=configurtion~1
168+
169+
170+
Using The Search Query Syntax To Build Complex Queries
171+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
172+
173+
The search query syntaxes described in the previous section
174+
can be used with one another to build complex queries.
175+
176+
Example queries:
177+
178+
- https://docs.readthedocs.io/?rtd_search=auto*%20redirect*
179+
- https://docs.readthedocs.io/?rtd_search=abandon*%20proj*
180+
- https://docs.readthedocs.io/?rtd_search=localisation~3%20of%20doc*
181+
182+
183+
.. _readthedocs-sphinx-search: https://readthedocs-sphinx-search.readthedocs.io/
184+
.. _GitHub issues: https://github.com/readthedocs/readthedocs.org/issues/new
185+
.. _main site search: https://readthedocs.org/search/?q=&type=file&version=latest
186+
.. _Kombu: http://docs.celeryproject.org/projects/kombu/en/master/
187+
.. _Celery: http://docs.celeryproject.org/en/master/
188+
.. _Simple Query String: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-simple-query-string-query.html#
189+
.. _Elasticsearch: https://www.elastic.co/products/elasticsearch
190+
.. _Levenshtein edit distance: https://en.wikipedia.org/wiki/Levenshtein_distance

0 commit comments

Comments
 (0)