| 1 |
.. _searchadapters: |
| 2 |
|
| 3 |
.. currentmodule:: sphinxcontrib.websupport.search |
| 4 |
|
| 5 |
Search adapters |
| 6 |
=============== |
| 7 |
|
| 8 |
To create a custom search adapter you will need to subclass the |
| 9 |
:class:`BaseSearch` class. Then create an instance of the new class and pass |
| 10 |
that as the *search* keyword argument when you create the :class:`~.WebSupport` |
| 11 |
object:: |
| 12 |
|
| 13 |
support = WebSupport(srcdir=srcdir, |
| 14 |
builddir=builddir, |
| 15 |
search=MySearch()) |
| 16 |
|
| 17 |
For more information about creating a custom search adapter, please see the |
| 18 |
documentation of the :class:`BaseSearch` class below. |
| 19 |
|
| 20 |
.. class:: BaseSearch |
| 21 |
|
| 22 |
Defines an interface for search adapters. |
| 23 |
|
| 24 |
.. versionchanged:: 1.6 |
| 25 |
|
| 26 |
BaseSearch class is moved to sphinxcontrib.websupport.search from |
| 27 |
sphinx.websupport.search. |
| 28 |
|
| 29 |
Methods |
| 30 |
------- |
| 31 |
|
| 32 |
The following methods are defined in the BaseSearch class. Some methods do not |
| 33 |
need to be overridden, but some (:meth:`~BaseSearch.add_document` and |
| 34 |
:meth:`~BaseSearch.handle_query`) must be overridden in your subclass. For a |
| 35 |
working example, look at the built-in adapter for whoosh. |
| 36 |
|
| 37 |
.. automethod:: BaseSearch.init_indexing |
| 38 |
|
| 39 |
.. automethod:: BaseSearch.finish_indexing |
| 40 |
|
| 41 |
.. automethod:: BaseSearch.feed |
| 42 |
|
| 43 |
.. automethod:: BaseSearch.add_document |
| 44 |
|
| 45 |
.. automethod:: BaseSearch.query |
| 46 |
|
| 47 |
.. automethod:: BaseSearch.handle_query |
| 48 |
|
| 49 |
.. automethod:: BaseSearch.extract_context |