Skip to content

Commit

Permalink
Updated documentation to include a couple more Sphinx directives. Ind…
Browse files Browse the repository at this point in the history
…ex is now more useful.
  • Loading branch information
toastdriven committed Oct 17, 2009
1 parent 82a43e8 commit 6163acd
Show file tree
Hide file tree
Showing 20 changed files with 361 additions and 154 deletions.
2 changes: 2 additions & 0 deletions docs/architecture_overview.rst
@@ -1,3 +1,5 @@
.. _ref-architecture-overview:

=====================
Architecture Overview
=====================
Expand Down
2 changes: 2 additions & 0 deletions docs/backend_support.rst
@@ -1,3 +1,5 @@
.. _ref-backend-support:

===============
Backend Support
===============
Expand Down
2 changes: 2 additions & 0 deletions docs/best_practices.rst
@@ -1,3 +1,5 @@
.. _ref-best-practices:

==============
Best Practices
==============
Expand Down
2 changes: 2 additions & 0 deletions docs/creating_new_backends.rst
@@ -1,3 +1,5 @@
.. _ref-creating-new-backends:

=====================
Creating New Backends
=====================
Expand Down
2 changes: 2 additions & 0 deletions docs/faceting.rst
@@ -1,3 +1,5 @@
.. _ref-faceting:

========
Faceting
========
Expand Down
2 changes: 2 additions & 0 deletions docs/faq.rst
@@ -1,3 +1,5 @@
.. _ref-frequently-asked-questions:

==============================
(In)Frequently Asked Questions
==============================
Expand Down
2 changes: 2 additions & 0 deletions docs/glossary.rst
@@ -1,3 +1,5 @@
.. _ref-glossary:

========
Glossary
========
Expand Down
3 changes: 3 additions & 0 deletions docs/haystack_theme/static/documentation.css
@@ -1,5 +1,8 @@
a, a:link, a:hover { background-color: transparent !important; color: #CAECFF; outline-color: transparent !important; text-decoration: underline; }
dl dt { text-decoration: underline; }
dl.class dt, dl.method dt { background-color: #444444; padding: 5px; text-decoration: none; }
tt.descname { font-weight: normal; }
dl.method dt span.optional { font-weight: normal; }
div#header { margin-bottom: 0px; }
div.document, div.related, div.footer { width: 900px; margin: 0 auto; }
div.document { margin-top: 10px; }
Expand Down
2 changes: 2 additions & 0 deletions docs/installing_search_engines.rst
@@ -1,3 +1,5 @@
.. _ref-installing-search-engines:

=========================
Installing Search Engines
=========================
Expand Down
2 changes: 2 additions & 0 deletions docs/running_tests.rst
@@ -1,3 +1,5 @@
.. _ref-running-tests:

=============
Running Tests
=============
Expand Down
58 changes: 40 additions & 18 deletions docs/searchbackend_api.rst
@@ -1,7 +1,11 @@
.. _ref-searchbackend-api:

=====================
``SearchBackend`` API
=====================

.. class:: SearchBackend(site=None)

The ``SearchBackend`` class handles interaction directly with the backend. The
search query it performs is usually fed to it from a ``SearchQuery`` class that
has been built for that backend.
Expand All @@ -16,25 +20,31 @@ access this class.
Method Reference
================

``get_identifier(self, obj_or_string)``
---------------------------------------
``get_identifier``
------------------

.. method:: SearchBackend.get_identifier(self, obj_or_string)

Get an unique identifier for the object or a string representing the
object.

If not overridden, uses <app_label>.<object_name>.<pk>.

``update(self, index, iterable)``
---------------------------------
``update``
----------

.. method:: SearchBackend.update(self, index, iterable)

Updates the backend when given a ``SearchIndex`` and a collection of
documents.

This method MUST be implemented by each backend, as it will be highly
specific to each one.

``remove(self, obj_or_string)``
-------------------------------
``remove``
----------

.. method:: SearchBackend.remove(self, obj_or_string)

Removes a document/object from the backend. Can be either a model
instance or the identifier (i.e. ``app_name.model_name.id``) in the
Expand All @@ -43,16 +53,20 @@ event the object no longer exists.
This method MUST be implemented by each backend, as it will be highly
specific to each one.

``clear(self, models=[])``
--------------------------
``clear``
---------

.. method:: SearchBackend.clear(self, models=[])

Clears the backend of all documents/objects for a collection of models.

This method MUST be implemented by each backend, as it will be highly
specific to each one.

``search(self, query_string, sort_by=None, start_offset=0, end_offset=None, fields='', highlight=False, facets=None, date_facets=None, query_facets=None, narrow_queries=None, spelling_query=None, limit_to_registered_models=True, **kwargs)``
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
``search``
----------

.. method:: SearchBackend.search(self, query_string, sort_by=None, start_offset=0, end_offset=None, fields='', highlight=False, facets=None, date_facets=None, query_facets=None, narrow_queries=None, spelling_query=None, limit_to_registered_models=True, **kwargs)

Takes a query to search on and returns dictionary.

Expand All @@ -66,32 +80,40 @@ results the search backend found.
This method MUST be implemented by each backend, as it will be highly
specific to each one.

``prep_value(self, value)``
---------------------------
``prep_value``
--------------

.. method:: SearchBackend.prep_value(self, value)

Hook to give the backend a chance to prep an attribute value before
sending it to the search engine.

By default, just force it to unicode.

``more_like_this(self, model_instance)``
----------------------------------------
``more_like_this``
------------------

.. method:: SearchBackend.more_like_this(self, model_instance)

Takes a model object and returns results the backend thinks are similar.

This method MUST be implemented by each backend, as it will be highly
specific to each one.

``build_schema(self, fields)``
------------------------------
``build_schema``
----------------

.. method:: SearchBackend.build_schema(self, fields)

Takes a dictionary of fields and returns schema information.

This method MUST be implemented by each backend, as it will be highly
specific to each one.

``build_registered_models_list(self)``
--------------------------------------
``build_registered_models_list``
--------------------------------

.. method:: SearchBackend.build_registered_models_list(self)

Builds a list of registered models for searching.

Expand Down
70 changes: 48 additions & 22 deletions docs/searchindex_api.rst
@@ -1,7 +1,11 @@
.. _ref-searchindex-api:

===================
``SearchIndex`` API
===================

.. class:: SearchIndex(model, backend=None)

The ``SearchIndex`` class allows the application developer a way to provide data to
the backend in a structured format. Developers familiar with Django's ``Form``
or ``Model`` classes should find the syntax for indexes familiar.
Expand Down Expand Up @@ -263,52 +267,70 @@ non-existent), merely an example of how to extend existing fields.
Method Reference
================

``get_queryset(self)``
-----------------------
``get_queryset``
----------------

.. method:: SearchIndex.get_queryset(self)

Get the default QuerySet to index when doing a full update.

Subclasses can override this method to avoid indexing certain objects.

``prepare(self, obj)``
----------------------
``prepare``
-----------

.. method:: SearchIndex.prepare(self, obj)

Fetches and adds/alters data before indexing.

``get_content_field(self)``
---------------------------
``get_content_field``
---------------------

.. method:: SearchIndex.get_content_field(self)

Returns the field that supplies the primary document to be indexed.

``update(self)``
----------------
``update``
----------

.. method:: SearchIndex.update(self)

Update the entire index.

``update_object(self, instance, **kwargs)``
-------------------------------------------
``update_object``
-----------------

.. method:: SearchIndex.update_object(self, instance, **kwargs)

Update the index for a single object. Attached to the class's
post-save hook.

``remove_object(self, instance, **kwargs)``
-------------------------------------------
``remove_object``
-----------------

.. method:: SearchIndex.remove_object(self, instance, **kwargs)

Remove an object from the index. Attached to the class's
post-delete hook.

``clear(self)``
---------------
``clear``
---------

.. method:: SearchIndex.clear(self)

Clear the entire index.

``reindex(self)``
-----------------
``reindex``
-----------

.. method:: SearchIndex.reindex(self)

Completely clear the index for this model and rebuild it.

``get_updated_field(self)``
---------------------------
``get_updated_field``
---------------------

.. method:: SearchIndex.get_updated_field(self)

Get the field name that represents the updated date for the model.

Expand All @@ -317,8 +339,10 @@ from the ``QuerySet``, enabling you to reindex only recent records. This
method should either return None (reindex everything always) or a
string of the ``Model``'s ``DateField``/``DateTimeField`` name.

``should_update(self, instance)``
---------------------------------
``should_update``
-----------------

.. method:: SearchIndex.should_update(self, instance)

Determine if an object should be updated in the index.

Expand All @@ -328,8 +352,10 @@ and return False if it is not to be indexed.

By default, returns True (always reindex).

``load_all_queryset(self)``
---------------------------
``load_all_queryset``
---------------------

.. method:: SearchIndex.load_all_queryset(self)

Provides the ability to override how objects get loaded in conjunction
with ``RelatedSearchQuerySet.load_all``. This is useful for post-processing the
Expand Down

0 comments on commit 6163acd

Please sign in to comment.