2010-07-15 13:25:12 -05:00
|
|
|
.. _searchadapters:
|
|
|
|
|
|
|
|
.. currentmodule:: sphinx.websupport.search
|
|
|
|
|
|
|
|
Search Adapters
|
|
|
|
===============
|
|
|
|
|
|
|
|
To create a custom search adapter you will need to subclass the
|
2010-08-21 12:15:14 -05:00
|
|
|
:class:`BaseSearch` class. Then create an instance of the new class and pass
|
|
|
|
that as the `search` keyword argument when you create the :class:`~.WebSupport`
|
|
|
|
object::
|
2010-07-15 13:25:12 -05:00
|
|
|
|
2010-08-21 12:15:14 -05:00
|
|
|
support = WebSupport(srcdir=srcdir,
|
|
|
|
builddir=builddir,
|
|
|
|
search=MySearch())
|
2010-07-15 13:25:12 -05:00
|
|
|
|
2010-08-21 12:15:14 -05:00
|
|
|
For more information about creating a custom search adapter, please see the
|
|
|
|
documentation of the :class:`BaseSearch` class below.
|
2010-07-15 13:25:12 -05:00
|
|
|
|
|
|
|
.. class:: BaseSearch
|
|
|
|
|
2010-08-21 12:15:14 -05:00
|
|
|
Defines an interface for search adapters.
|
|
|
|
|
2010-07-15 13:25:12 -05:00
|
|
|
|
|
|
|
BaseSearch Methods
|
|
|
|
~~~~~~~~~~~~~~~~~~
|
|
|
|
|
2010-08-21 12:15:14 -05:00
|
|
|
The following methods are defined in the BaseSearch class. Some methods do
|
|
|
|
not need to be overridden, but some (:meth:`~BaseSearch.add_document` and
|
|
|
|
:meth:`~BaseSearch.handle_query`) must be overridden in your subclass. For a
|
|
|
|
working example, look at the built-in adapter for whoosh.
|
2010-07-15 13:25:12 -05:00
|
|
|
|
2010-08-21 12:15:14 -05:00
|
|
|
.. automethod:: BaseSearch.init_indexing
|
2010-07-15 13:25:12 -05:00
|
|
|
|
2010-08-21 12:15:14 -05:00
|
|
|
.. automethod:: BaseSearch.finish_indexing
|
2010-07-15 13:25:12 -05:00
|
|
|
|
2010-08-21 12:15:14 -05:00
|
|
|
.. automethod:: BaseSearch.feed
|
2010-07-15 13:25:12 -05:00
|
|
|
|
2010-08-21 12:15:14 -05:00
|
|
|
.. automethod:: BaseSearch.add_document
|
2010-07-15 13:25:12 -05:00
|
|
|
|
2010-08-21 12:15:14 -05:00
|
|
|
.. automethod:: BaseSearch.query
|
2010-07-15 13:25:12 -05:00
|
|
|
|
2010-08-21 12:15:14 -05:00
|
|
|
.. automethod:: BaseSearch.handle_query
|
2010-07-15 13:25:12 -05:00
|
|
|
|
2010-08-21 12:15:14 -05:00
|
|
|
.. automethod:: BaseSearch.extract_context
|