Skip to content

Commit

Permalink
Merge pull request #108 from Sparrho/issue-105b
Browse files Browse the repository at this point in the history
Version 1.2.1: updated README and patch for iterables in utils
  • Loading branch information
ChristopherRabotin committed Aug 10, 2015
2 parents 889ec3f + 2f8470f commit 25e2d01
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 18 deletions.
42 changes: 26 additions & 16 deletions README.rst
@@ -1,5 +1,15 @@
|Build Status| |Coverage Status| # Purpose Bungiesearch is a Django
wrapper for
Bungiesearch
============

|Build Status| |Coverage Status|

.. contents:: Table of contents
:depth: 2

Purpose
=======

Bungiesearch is a Django wrapper for
`elasticsearch-dsl-py <https://github.com/elasticsearch/elasticsearch-dsl-py>`__.
It inherits from elasticsearch-dsl-py's ``Search`` class, so all the
fabulous features developed by the elasticsearch-dsl-py team are also
Expand Down Expand Up @@ -438,7 +448,7 @@ Class methods
~~~~~~~~~~~~~

matches\_indexing\_condition
''''''''''''''''''''''''''''
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Override this function to specify whether an item should be indexed or
not. This is useful when defining multiple indices (and ModelIndex
Expand Down Expand Up @@ -467,7 +477,7 @@ could also be a ``tuple``. ##### model *Required:* defines the Django
model for which this ModelIndex is applicable.

fields
''''''
^^^^^^

*Optional:* list of fields (or columns) which must be fetched when
serializing the object for elasticsearch, or when reverse mapping the
Expand All @@ -477,13 +487,13 @@ can be fetched and may lead to errors when serializing the object. It is
recommended to use the ``exclude`` attribute instead (cf. below).

exclude
'''''''
^^^^^^^

*Optional:* list of fields (or columns) which must not be fetched when
serializing or deserializing the object.

hotfixes
''''''''
^^^^^^^^

*Optional:* a dictionary whose keys are index fields and whose values
are dictionaries which define `core type
Expand All @@ -496,28 +506,28 @@ is set to
(``{'analyzer': 'snowball'}``).

additional\_fields
''''''''''''''''''
^^^^^^^^^^^^^^^^^^

*Optional:* additional fields to fetch for mapping, may it be for
``eval_as`` fields or when returning the object from the database.

id\_field
'''''''''
^^^^^^^^^

*Optional:* the model field to use as a unique ID for elasticsearch's
metadata ``_id``. Defaults to ``id`` (also called
```pk`` <https://docs.djangoproject.com/en/dev/topics/db/models/#automatic-primary-key-fields>`__).

updated\_field
''''''''''''''
^^^^^^^^^^^^^^

*Optional:* set the model's field which can be filtered on dates in
order to find when objects have been updated. Note, this is *mandatory*
to use ``--start`` and/or ``--end`` when updating index (with
``search_index --update``).

optimize\_queries
'''''''''''''''''
^^^^^^^^^^^^^^^^^

*Optional:* set to True to make efficient queries when automatically
mapping to database objects. This will *always* restrict fetching to the
Expand All @@ -528,22 +538,22 @@ will use the same fields as ``optimize_queries``, or
``.fields()`` call.

indexing\_query
'''''''''''''''
^^^^^^^^^^^^^^^

*Optional:* set to a QuerySet instance to specify the query used when
the search\_index command is ran to index. This **does not** affect how
each piece of content is indexed.

default
'''''''
^^^^^^^

Enables support for a given model to be indexed on several elasticsearch
indices. Set to ``False`` on all but the default index. **Note**: if all
managed models are set with ``default=False`` then Bungiesearch will
fail to find and index that model.

Example
^^^^^^^
~~~~~~~

Indexes all objects of ``Article``, as long as their ``updated``
datetime is less than `21 October 2015
Expand Down Expand Up @@ -629,14 +639,14 @@ Although not mandatory, the ``Meta`` subclass enabled custom naming and
model restrictions for a search alias.

models
''''''
^^^^^^

*Optional:* ``list`` (or ``tuple``) of Django models which are allowed
to use this search alias. If a model which is not allowed to use this
SearchAlias tries it, a ``ValueError`` will be raised.

alias\_name
'''''''''''
^^^^^^^^^^^

*Optional:* A string corresponding the suffix name of this search alias.
Defaults to the lower case class name.
Expand All @@ -656,7 +666,7 @@ module, and use both in conjunction as such:
These aliases can be concatenated ad vitam aeternam.

Sophisticated example
^^^^^^^^^^^^^^^^^^^^^
~~~~~~~~~~~~~~~~~~~~~

This example shows that we can have some fun with search aliases. In
this case, we define a Range alias which is applicable to any field on
Expand Down
2 changes: 1 addition & 1 deletion bungiesearch/utils.py
Expand Up @@ -27,7 +27,7 @@ def update_index(model_items, model_name, action='index', bulk_size=100, num_doc
'''
src = Bungiesearch()

if action == 'delete' and not isinstance(model_items, (list, tuple)):
if action == 'delete' and not hasattr(model_items, '__iter__'):
raise ValueError("If action is 'delete', model_items must be an iterable of primary keys.")

logging.info('Getting index for model {}.'.format(model_name))
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -3,7 +3,7 @@
from os.path import join, dirname
from setuptools import setup, find_packages

VERSION = (1, 2, 0)
VERSION = (1, 2, 1)
__version__ = VERSION
__versionstr__ = '.'.join(map(str, VERSION))

Expand Down

0 comments on commit 25e2d01

Please sign in to comment.