| 1 |
================================== |
| 2 |
Haystack for Django REST Framework |
| 3 |
================================== |
| 4 |
|
| 5 |
Contents: |
| 6 |
|
| 7 |
.. toctree:: |
| 8 |
:maxdepth: 2 |
| 9 |
|
| 10 |
01_intro |
| 11 |
02_autocomplete |
| 12 |
03_geospatial |
| 13 |
04_highlighting |
| 14 |
05_more_like_this |
| 15 |
06_term_boost |
| 16 |
07_faceting |
| 17 |
08_permissions |
| 18 |
09_multiple_indexes |
| 19 |
10_tips_n_tricks |
| 20 |
apidoc/modules |
| 21 |
|
| 22 |
About |
| 23 |
===== |
| 24 |
Small library aiming to simplify using Haystack with Django REST Framework |
| 25 |
|
| 26 |
Features |
| 27 |
======== |
| 28 |
|
| 29 |
Supported Python and Django versions: |
| 30 |
|
| 31 |
- Python 3.6+ |
| 32 |
- `All supported versions of Django <https://www.djangoproject.com/download/#supported-versions>`_ |
| 33 |
|
| 34 |
|
| 35 |
Installation |
| 36 |
============ |
| 37 |
It's in the cheese shop! |
| 38 |
|
| 39 |
.. code-block:: none |
| 40 |
|
| 41 |
$ pip install drf-haystack |
| 42 |
|
| 43 |
|
| 44 |
Requirements |
| 45 |
============ |
| 46 |
- A Supported Django install |
| 47 |
- Django REST Framework v3.2.0 and later |
| 48 |
- Haystack v2.5 and later |
| 49 |
- A supported search engine such as Solr, Elasticsearch, Whoosh, etc. |
| 50 |
- Python bindings for the chosen backend (see below). |
| 51 |
- (geopy and libgeos if you want to use geo spatial filtering) |
| 52 |
|
| 53 |
Python bindings |
| 54 |
--------------- |
| 55 |
|
| 56 |
You will also need to install python bindings for the search engine you'll use. |
| 57 |
|
| 58 |
Elasticsearch |
| 59 |
............. |
| 60 |
|
| 61 |
See haystack `Elasticsearch <https://django-haystack.readthedocs.io/en/v2.4.1/installing_search_engines.html#elasticsearch>`_ |
| 62 |
docs for details |
| 63 |
|
| 64 |
.. code-block:: none |
| 65 |
|
| 66 |
$ pip install elasticsearch<2.0.0 # For Elasticsearch 1.x |
| 67 |
$ pip install elasticsearch>=2.0.0,<3.0.0 # For Elasticsearch 2.x |
| 68 |
|
| 69 |
Solr |
| 70 |
.... |
| 71 |
|
| 72 |
See haystack `Solr <https://django-haystack.readthedocs.io/en/v2.4.1/installing_search_engines.html#solr>`_ |
| 73 |
docs for details. |
| 74 |
|
| 75 |
.. code-block:: none |
| 76 |
|
| 77 |
$ pip install pysolr |
| 78 |
|
| 79 |
Whoosh |
| 80 |
...... |
| 81 |
|
| 82 |
See haystack `Whoosh <https://django-haystack.readthedocs.io/en/v2.4.1/installing_search_engines.html#whoosh>`_ |
| 83 |
docs for details. |
| 84 |
|
| 85 |
.. code-block:: none |
| 86 |
|
| 87 |
$ pip install whoosh |
| 88 |
|
| 89 |
Xapian |
| 90 |
...... |
| 91 |
|
| 92 |
See haystack `Xapian <https://django-haystack.readthedocs.io/en/v2.4.1/installing_search_engines.html#xapian>`_ |
| 93 |
docs for details. |
| 94 |
|
| 95 |
|
| 96 |
Contributors |
| 97 |
============ |
| 98 |
|
| 99 |
This library has mainly been written by `me <https://github.com/rhblind>`_ while working |
| 100 |
at `Inonit <https://github.com/inonit>`_. I have also had some help from these amazing people! |
| 101 |
Thanks guys! |
| 102 |
|
| 103 |
- See the full list of `contributors <https://github.com/rhblind/drf-haystack/graphs/contributors>`_. |
| 104 |
|
| 105 |
Changelog |
| 106 |
========= |
| 107 |
|
| 108 |
v1.9.1 |
| 109 |
------ |
| 110 |
*Release date: 2024-11-05* |
| 111 |
|
| 112 |
- Add deprecation warning about potential future sunsetting of the project, due to lack of active maintainers. |
| 113 |
|
| 114 |
v1.9 |
| 115 |
------ |
| 116 |
*Release date: 2024-11-04* |
| 117 |
|
| 118 |
- Return an empty query object instead of an empty list when no filter is passed (:drf-issue:`202`). |
| 119 |
- add "id" as an optional value of the serializer fields returning the haystack internal id (:drf-issue:`193`). |
| 120 |
- Update supported versions of main dependencies (Django >=2.2,<5.2; djangorestframework >=3.12.0,<3.16; django-haystack >=2.8,<3.4). |
| 121 |
|
| 122 |
v1.8.13 |
| 123 |
------ |
| 124 |
*Release date: 2023-10-04* |
| 125 |
|
| 126 |
- Support patch versions of Django 4.2.x. |
| 127 |
- Upgrade a few dependencies. |
| 128 |
|
| 129 |
v1.8.12 |
| 130 |
------ |
| 131 |
*Release date: 2023-01-03* |
| 132 |
|
| 133 |
- Updated supported Django-Haystack versions |
| 134 |
|
| 135 |
v1.8.11 |
| 136 |
------ |
| 137 |
*Release date: 2021-08-27* |
| 138 |
|
| 139 |
- Updated supported Django-Haystack versions |
| 140 |
|
| 141 |
|
| 142 |
v1.8.10 |
| 143 |
------ |
| 144 |
*Release date: 2021-04-12* |
| 145 |
|
| 146 |
- Updated supported Django versions |
| 147 |
- Updated supported Python versions |
| 148 |
|
| 149 |
|
| 150 |
v1.8.9 |
| 151 |
------ |
| 152 |
*Release date: 2020-10-05* |
| 153 |
|
| 154 |
- Updated supported Django versions |
| 155 |
|
| 156 |
|
| 157 |
v1.8.8 |
| 158 |
------ |
| 159 |
*Release date: 2020-09-28* |
| 160 |
|
| 161 |
- Updated supported DRF versions |
| 162 |
|
| 163 |
|
| 164 |
v1.8.7 |
| 165 |
------ |
| 166 |
*Release date: 2020-08-01* |
| 167 |
|
| 168 |
- Updated supported Python, Haystack and DRF versions |
| 169 |
|
| 170 |
|
| 171 |
v1.8.6 |
| 172 |
------ |
| 173 |
*Release date: 2019-10-13* |
| 174 |
|
| 175 |
- Fixed :drf-issue:`139`. Overriding declared fields must now use ``serializers.SerializerMethodField()`` and are |
| 176 |
handled by stock DRF. We don't need any custom functionality for this. |
| 177 |
- Added support for Django REST Framework v3.10.x |
| 178 |
- Dropped Python 2.x support |
| 179 |
|
| 180 |
v1.8.5 |
| 181 |
------ |
| 182 |
*Release date: 2019-05-21* |
| 183 |
|
| 184 |
- Django2.2 support |
| 185 |
- Django REST Framework 3.9.x support |
| 186 |
|
| 187 |
v1.8.4 |
| 188 |
------ |
| 189 |
*Release date: 2018-08-15* |
| 190 |
|
| 191 |
- Fixed Django2.1 support |
| 192 |
- Replaced `requirements.txt` with `Pipfile` for development dependencies management |
| 193 |
|
| 194 |
v1.8.3 |
| 195 |
------ |
| 196 |
*Release date: 2018-06-16* |
| 197 |
|
| 198 |
- Fixed issues with ``__in=[...]`` and ``__range=[...]`` filters. Closes :drf-issue:`128`. |
| 199 |
|
| 200 |
v1.8.2 |
| 201 |
------ |
| 202 |
*Release date: 2018-05-22* |
| 203 |
|
| 204 |
- Fixed issue with ``_get_count`` for DRF v3.8 |
| 205 |
|
| 206 |
v1.8.1 |
| 207 |
------ |
| 208 |
*Release date: 2018-04-20* |
| 209 |
|
| 210 |
- Fixed errors in test suite which caused all tests to run on Elasticsearch 1.x |
| 211 |
|
| 212 |
v1.8.0 |
| 213 |
------ |
| 214 |
*Release date: 2018-04-16* |
| 215 |
|
| 216 |
**This release was pulled because of critical errors in the test suite.** |
| 217 |
|
| 218 |
- Dropped support for Django v1.10.x and added support for Django v2.0.x |
| 219 |
- Updated minimum Django REST Framework requirement to v3.7 |
| 220 |
- Updated minimum Haystack requirements to v2.8 |
| 221 |
|
| 222 |
v1.7.1rc2 |
| 223 |
--------- |
| 224 |
*Release date: 2018-01-30* |
| 225 |
|
| 226 |
- Fixes issues with building documentation. |
| 227 |
- Fixed some minor typos in documentation. |
| 228 |
- Dropped unittest2 in favor of standard lib unittest |
| 229 |
|
| 230 |
v1.7.1rc1 |
| 231 |
--------- |
| 232 |
*Release date: 2018-01-06* |
| 233 |
|
| 234 |
- Locked Django versions in order to comply with Haystack requirements. |
| 235 |
- Requires development release of Haystack (v2.7.1dev0). |
| 236 |
|
| 237 |
v1.7.0 |
| 238 |
------ |
| 239 |
*Release date: 2018-01-06 (Removed from pypi due to critical bugs)* |
| 240 |
|
| 241 |
- Bumping minimum support for Django to v1.10. |
| 242 |
- Bumping minimum support for Django REST Framework to v1.6.0 |
| 243 |
- Adding support for Elasticsearch 2.x Haystack backend |
| 244 |
|
| 245 |
v1.6.1 |
| 246 |
------ |
| 247 |
*Release date: 2017-01-13* |
| 248 |
|
| 249 |
- Updated docs with correct name for libgeos-c1. |
| 250 |
- Updated ``.travis.yml`` with correct name for libgeos-c1. |
| 251 |
- Fixed an issue where queryset in the whould be evaluated if attribute is set but has no results, |
| 252 |
thus triggering the wrong clause in condition check. :drf-pr:`88` closes :drf-issue:`86`. |
| 253 |
|
| 254 |
|
| 255 |
v1.6.0 |
| 256 |
------ |
| 257 |
*Release date: 2016-11-08* |
| 258 |
|
| 259 |
- Added Django 1.10 compatibility. |
| 260 |
- Fixed multiple minor issues. |
| 261 |
|
| 262 |
|
| 263 |
v1.6.0rc3 |
| 264 |
--------- |
| 265 |
*Release date: 2016-06-29* |
| 266 |
|
| 267 |
- Fixed :drf-issue:`61`. Introduction of custom serializers for serializing faceted objects contained a |
| 268 |
breaking change. |
| 269 |
|
| 270 |
v1.6.0rc2 |
| 271 |
--------- |
| 272 |
*Release date: 2016-06-28* |
| 273 |
|
| 274 |
- Restructured and updated documentation |
| 275 |
- Added support for using a custom serializer when serializing faceted objects. |
| 276 |
|
| 277 |
v1.6.0rc1 |
| 278 |
--------- |
| 279 |
*Release date: 2016-06-24* |
| 280 |
|
| 281 |
.. note:: |
| 282 |
|
| 283 |
**This release include breaking changes to the API** |
| 284 |
|
| 285 |
- Dropped support for Python 2.6, Django 1.5, 1.6 and 1.7 |
| 286 |
- Will follow `Haystack's <https://github.com/django-haystack/django-haystack#requirements>`_ supported versions |
| 287 |
|
| 288 |
|
| 289 |
- Removed deprecated ``SQHighlighterMixin``. |
| 290 |
- Removed redundant ``BaseHaystackGEOSpatialFilter``. If name of ``indexes.LocationField`` needs to be changed, subclass the ``HaystackGEOSpatialFilter`` directly. |
| 291 |
- Reworked filters: |
| 292 |
- More consistent naming of methods. |
| 293 |
- All filters follow the same logic for building and applying filters and exclusions. |
| 294 |
- All filter classes use a ``QueryBuilder`` class for working out validation and building queries which are to be passed to the ``SearchQuerySet``. |
| 295 |
- Most filters does *not* inherit from ``HaystackFilter`` anymore (except ``HaystackAutocompleteFilter`` and ``HaystackHighlightFilter``) and will no longer do basic field filtering. Filters should be properly placed in the ``filter_backends`` class attribute in their respective order to be applied. This solves issues where inherited filters responds to query parameters they should ignore. |
| 296 |
- HaystackFacetSerializer ``narrow_url`` now returns an absolute url. |
| 297 |
- HaystackFacetSerializer now properly serializes ``MultiValueField`` and ``FacetMultiValueField`` items as a JSON Array. |
| 298 |
- ``HaystackGenericAPIView.get_object()`` optional ``model`` query parameter now requires a ``app_label.model`` instead of just the ``model``. |
| 299 |
- Extracted internal fields and serializer from the ``HaystackFacetSerializer`` in order to ease customization. |
| 300 |
- ``HaystackFacetSerializer`` now supports all three `builtin <http://www.django-rest-framework.org/api-guide/pagination/#api-reference>`_ pagination classes, and a hook to support custom pagination classes. |
| 301 |
- Extracted the ``more-like-this`` detail route and ``facets`` list route from the generic HaystackViewSet. |
| 302 |
- Support for ``more-like-this`` is available as a :class:`drf_haystack.mixins.MoreLikeThisMixin` class. |
| 303 |
- Support for ``facets`` is available as a :class:`drf_haystack.mixins.FacetMixin` class. |
| 304 |
|
| 305 |
v1.5.6 |
| 306 |
------ |
| 307 |
*Release date: 2015-12-02* |
| 308 |
|
| 309 |
- Fixed a bug where ``ignore_fields`` on ``HaystackSerializer`` did not work unless ``exclude`` evaluates |
| 310 |
to ``True``. |
| 311 |
- Removed ``elasticsearch`` from ``install_requires``. Elasticsearch should not be a mandatory requirement, |
| 312 |
since it's useless if not using Elasticsearch as backend. |
| 313 |
|
| 314 |
v1.5.5 |
| 315 |
------ |
| 316 |
*Release date: 2015-10-31* |
| 317 |
|
| 318 |
- Added support for Django REST Framework 3.3.0 (Only for Python 2.7/Django 1.7 and above) |
| 319 |
- Locked elasticsearch < 2.0.0 (See :drf-issue:`29`) |
| 320 |
|
| 321 |
v1.5.4 |
| 322 |
------ |
| 323 |
*Release date: 2015-10-08* |
| 324 |
|
| 325 |
- Added support for serializing faceted results. Closing :drf-issue:`27`. |
| 326 |
|
| 327 |
v1.5.3 |
| 328 |
------ |
| 329 |
*Release date: 2015-10-05* |
| 330 |
|
| 331 |
- Added support for :ref:`faceting-label` (Github :drf-issue:`11`). |
| 332 |
|
| 333 |
v1.5.2 |
| 334 |
------ |
| 335 |
*Release date: 2015-08-23* |
| 336 |
|
| 337 |
- Proper support for :ref:`multiple-indexes-label` (Github :drf-issue:`22`). |
| 338 |
- Experimental support for :ref:`term-boost-label` (This seems to have some issues upstreams, |
| 339 |
so unfortunately it does not really work as expected). |
| 340 |
- Support for negate in filters. |
| 341 |
|
| 342 |
v1.5.1 |
| 343 |
------ |
| 344 |
*Release date: 2015-07-28* |
| 345 |
|
| 346 |
- Support for More Like This results (Github :drf-issue:`10`). |
| 347 |
- Deprecated ``SQHighlighterMixin`` in favor of ``HaystackHighlightFilter``. |
| 348 |
- ``HaystackGenericAPIView`` now returns 404 for detail views if more than one entry is found (Github :drf-issue:`19`). |
| 349 |
|
| 350 |
v1.5.0 |
| 351 |
------ |
| 352 |
*Release date: 2015-06-29* |
| 353 |
|
| 354 |
- Added support for field lookups in queries, such as ``field__contains=foobar``. |
| 355 |
Check out `Haystack docs <https://django-haystack.readthedocs.io/en/latest/searchqueryset_api.html?highlight=field%20lookup#field-lookups>`_ |
| 356 |
for details. |
| 357 |
- Added default ``permission_classes`` on ``HaystackGenericAPIView`` in order to avoid crash when |
| 358 |
using global permission classes on REST Framework. See :ref:`permissions-label` for details. |
| 359 |
|
| 360 |
v1.4 |
| 361 |
---- |
| 362 |
*Release date: 2015-06-15* |
| 363 |
|
| 364 |
- Fixed issues for Geo spatial filtering on django-haystack v2.4.x with Elasticsearch. |
| 365 |
- A serializer class now accepts a list or tuple of ``ignore_field`` to bypass serialization. |
| 366 |
- Added support for Highlighting. |
| 367 |
|
| 368 |
v1.3 |
| 369 |
---- |
| 370 |
*Release date: 2015-05-19* |
| 371 |
|
| 372 |
- ``HaystackGenericAPIView().get_object()`` now returns Http404 instead of an empty ``SearchQueryset`` |
| 373 |
if no object is found. This mimics the behaviour from ``GenericAPIView().get_object()``. |
| 374 |
- Removed hard dependencies for ``geopy`` and ``libgeos`` (See Github :drf-issue:`5`). This means |
| 375 |
that if you want to use the ``HaystackGEOSpatialFilter``, you have to install these libraries |
| 376 |
manually. |
| 377 |
|
| 378 |
v1.2 |
| 379 |
---- |
| 380 |
*Release date: 2015-03-23* |
| 381 |
|
| 382 |
- Fixed ``MissingDependency`` error when using another search backend than Elasticsearch. |
| 383 |
- Fixed converting distance to D object before filtering in HaystackGEOSpatialFilter. |
| 384 |
- Added Python 3 classifier. |
| 385 |
|
| 386 |
v1.1 |
| 387 |
---- |
| 388 |
*Release date: 2015-02-16* |
| 389 |
|
| 390 |
- Full coverage (almost) test suite |
| 391 |
- Documentation |
| 392 |
- Beta release Development classifier |
| 393 |
|
| 394 |
v1.0 |
| 395 |
---- |
| 396 |
*Release date: 2015-02-14* |
| 397 |
|
| 398 |
- Initial release. |
| 399 |
|
| 400 |
|
| 401 |
Indices and tables |
| 402 |
================== |
| 403 |
|
| 404 |
* :ref:`genindex` |
| 405 |
* :ref:`modindex` |
| 406 |
* :ref:`search` |