Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for retry param for Whoosh file writer #2

Open
wants to merge 50 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
8cb00e0
Fix haystack.__version__
tomkins Jul 28, 2017
7b6e799
Change fallback __version__ to be a string
tomkins Jul 29, 2017
11d3a13
Python installs setuptools by default already
ecederstrand Sep 30, 2019
a5bb8df
Add setuptools_scm to setup.cfg instead
ecederstrand Sep 30, 2019
5fbddcc
setup_requires in setup.py is not fully supported by pip
ecederstrand Sep 30, 2019
ee12701
using six replace django six
the5fire Oct 11, 2019
aaf7944
Update tutorial.rst
Asyncinfo Oct 15, 2019
49eacb3
Merge pull request #1688 from Asyncinfo/patch-3
acdha Oct 15, 2019
79ec0a3
Update loading.py
andreasofthings Dec 2, 2019
4d03346
Update .travis.yml
andreasofthings Dec 2, 2019
647edcb
Merge pull request #1696 from andreasofthings/patch-1
acdha Dec 3, 2019
ffe6dcd
Merge pull request #1686 from ecederstrand/patch-1
acdha Dec 9, 2019
abd5cd6
Merge branch 'master' into fix-version
tomkins Dec 21, 2019
2e6c4a9
Merge pull request #1535 from tomkins/fix-version
acdha Dec 23, 2019
5af8ace
Update __init__.py
MrKioZ Jan 19, 2020
d4494a6
Update __init__.py
MrKioZ Jan 19, 2020
c3c68e3
Update __init__.py
MrKioZ Jan 19, 2020
e1b4f5a
Update setup.py
MrKioZ Jan 19, 2020
87bd4c1
Merge pull request #1710 from MrKioZ/master
acdha Jan 20, 2020
a2b27a4
Travis CI: upgrade to running on Xenial
acdha Dec 3, 2019
57bf3f0
Upgrade package versions
acdha Dec 3, 2019
d631eec
Upgrade to Ubuntu 18.04
acdha Dec 3, 2019
74d4978
Update packages for bionic
sk1p Jan 24, 2020
ecbce6f
Remove Python 3.4
sk1p Jan 24, 2020
1d6c9af
solr downloader: catch ConnectionError and try next mirror
sk1p Jan 24, 2020
8d5b73f
travis: remove obsolete excludes
sk1p Jan 24, 2020
9ed236d
travis: downgrade to openjdk 8
sk1p Jan 24, 2020
087861e
point JAVA_HOME to openjdk-8
sk1p Jan 24, 2020
e6b91ee
travis: add debugging output for elasticsearch service
sk1p Jan 24, 2020
42cc4d0
try to run elasticsearch via docker
sk1p Jan 24, 2020
f8238ee
Travis: try to test w/ pypy3
sk1p Jan 24, 2020
07967f3
Travis: fix linting errors, warnings
sk1p Jan 24, 2020
037eed7
Run solr via docker
sk1p Jan 24, 2020
2219d11
make solr start script callable from other directories
sk1p Jan 24, 2020
4b84faa
test_build_schema: properly restore monkey patched settings
sk1p Jan 24, 2020
1e8ac20
add linebreaks to make docker command readable
sk1p Jan 24, 2020
6c1381f
Update tox.ini to match Python versions in travis
sk1p Jan 24, 2020
2423f9d
Revert "Run solr via docker"
sk1p Jan 27, 2020
e072df9
Merge pull request #1714 from sk1p/update-travis-dist
acdha Jan 28, 2020
ccb8b82
Merge branch 'master' into fix-six-for-django3.0
acdha Jan 28, 2020
7773b7f
Merge pull request #1689 from the5fire/fix-six-for-django3.0
acdha Jan 28, 2020
47a5352
Drop support for Python 2 and old versions of Django. Add support for…
solarissmoke Feb 12, 2020
193b418
Merge pull request #1720 from solarissmoke/feature/django3
acdha Feb 12, 2020
a948e37
Fixed hardcoded default connection alias
fakharmakhtar Feb 12, 2020
ac7b750
Merge pull request #1721 from fakhar362/issues/default-alias
acdha Feb 13, 2020
d03e0ac
Fix simple typo: specifially -> specifically
timgates42 Feb 17, 2020
d957aea
Merge pull request #1724 from timgates42/bugfix/typo_specifically
acdha Feb 17, 2020
2cb04b9
doc update -- fixes broken link
amites Mar 4, 2020
ea3f8c9
Merge pull request #1727 from amites/patch-1
acdha Mar 5, 2020
6a25a4e
Add support for retry param for Whoosh file writer
RouganStriker Jan 29, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 44 additions & 66 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
sudo: required
dist: trusty
os: linux
dist: bionic
language: python
python:
- 2.7
- 3.4
- 3.5
- 3.6
- pypy
- 3.7
- 3.8
- pypy3
services:
- docker

cache:
apt: true
Expand All @@ -17,37 +19,26 @@ cache:
addons:
apt_packages:
- binutils
- default-jdk
- openjdk-8-jdk
- gdal-bin
- libgdal1h
- libgeos-c1
- libgdal20
- libgeos-c1v5
- libproj-dev
- libxapian22
- python-xapian
- wajig

before_install:
- sudo apt-get install -qy default-jre
- mkdir -p $HOME/download-cache
# See https://www.elastic.co/guide/en/elasticsearch/reference/current/deb.html#deb-repo
- wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
- >
if [[ $VERSION_ES == '>=2.0.0,<3.0.0' ]];
if [[ $VERSION_ES == '>=2,<3' ]];
then
echo "deb http://packages.elastic.co/elasticsearch/2.x/debian stable main" | sudo tee -a /etc/apt/sources.list.d/elasticsearch-2.x.list
sudo apt-get update
sudo apt-get -qy --allow-downgrades install elasticsearch=2.4.6
elif [[ $VERSION_ES == '>=5.0.0,<6.0.0' ]];
docker run -d -p 9200:9200 elasticsearch:2.4.6-alpine
elif [[ $VERSION_ES == '>=5,<6' ]];
then
echo "deb https://artifacts.elastic.co/packages/5.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elasticsearch-5.x.list
sudo apt-get update -qy
sudo apt-get -y --allow-downgrades install elasticsearch=5.6.10
docker run -d -p 9200:9200 elasticsearch:5.6.10-alpine
else
echo "deb http://packages.elastic.co/elasticsearch/1.7/debian stable main" | sudo tee -a /etc/apt/sources.list.d/elasticsearch-1.7.list
sudo apt-get update -qy
sudo apt-get -qy --allow-downgrades install elasticsearch=1.7.6
docker run -d -p 9200:9200 elasticsearch:1.7.6-alpine
fi
- sudo service elasticsearch restart

install:
- pip install --upgrade setuptools
Expand All @@ -66,50 +57,37 @@ after_success:
- codecov

env:
matrix:
- DJANGO_VERSION=">=1.11,<2.0" VERSION_ES=">=1.0.0,<2.0.0"
- DJANGO_VERSION=">=2.0,<2.1" VERSION_ES=">=1.0.0,<2.0.0"
- DJANGO_VERSION=">=2.1,<2.2" VERSION_ES=">=1.0.0,<2.0.0"
- DJANGO_VERSION=">=1.11,<2.0" VERSION_ES=">=2.0.0,<3.0.0"
- DJANGO_VERSION=">=2.0,<2.1" VERSION_ES=">=2.0.0,<3.0.0"
- DJANGO_VERSION=">=2.1,<2.2" VERSION_ES=">=2.0.0,<3.0.0"
- DJANGO_VERSION=">=1.11,<2.0" VERSION_ES=">=5.0.0,<6.0.0"
- DJANGO_VERSION=">=2.0,<2.1" VERSION_ES=">=5.0.0,<6.0.0"
- DJANGO_VERSION=">=2.1,<2.2" VERSION_ES=">=5.0.0,<6.0.0"
matrix:
global:
- JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
jobs:
- DJANGO_VERSION=">=2.2,<3.0" VERSION_ES=">=1,<2"
- DJANGO_VERSION=">=3.0,<3.1" VERSION_ES=">=1,<2"
- DJANGO_VERSION=">=2.2,<3.0" VERSION_ES=">=2,<3"
- DJANGO_VERSION=">=3.0,<3.1" VERSION_ES=">=2,<3"
- DJANGO_VERSION=">=2.2,<3.0" VERSION_ES=">=5,<6"
- DJANGO_VERSION=">=3.0,<3.1" VERSION_ES=">=5,<6"
jobs:
allow_failures:
- python: 'pypy'
- python: 'pypy3'
exclude:
- python: 2.7
env: DJANGO_VERSION=">=2.0,<2.1" VERSION_ES=">=5.0.0,<6.0.0"
- python: 2.7
env: DJANGO_VERSION=">=2.0,<2.1" VERSION_ES=">=2.0.0,<3.0.0"
- python: 2.7
env: DJANGO_VERSION=">=2.0,<2.1" VERSION_ES=">=1.0.0,<2.0.0"
- python: 2.7
env: DJANGO_VERSION=">=2.1,<2.2" VERSION_ES=">=5.0.0,<6.0.0"
- python: 2.7
env: DJANGO_VERSION=">=2.1,<2.2" VERSION_ES=">=2.0.0,<3.0.0"
- python: 2.7
env: DJANGO_VERSION=">=2.1,<2.2" VERSION_ES=">=1.0.0,<2.0.0"
- python: 3.4
env: DJANGO_VERSION=">=2.1,<2.2" VERSION_ES=">=5.0.0,<6.0.0"
- python: 3.4
env: DJANGO_VERSION=">=2.1,<2.2" VERSION_ES=">=2.0.0,<3.0.0"
- python: 3.4
env: DJANGO_VERSION=">=2.1,<2.2" VERSION_ES=">=1.0.0,<2.0.0"
- python: pypy
env: DJANGO_VERSION=">=2.0,<2.1" VERSION_ES=">=5.0.0,<6.0.0"
- python: pypy
env: DJANGO_VERSION=">=2.0,<2.1" VERSION_ES=">=2.0.0,<3.0.0"
- python: pypy
env: DJANGO_VERSION=">=2.0,<2.1" VERSION_ES=">=1.0.0,<2.0.0"
- python: pypy
env: DJANGO_VERSION=">=2.1,<2.2" VERSION_ES=">=5.0.0,<6.0.0"
- python: pypy
env: DJANGO_VERSION=">=2.1,<2.2" VERSION_ES=">=2.0.0,<3.0.0"
- python: pypy
env: DJANGO_VERSION=">=2.1,<2.2" VERSION_ES=">=1.0.0,<2.0.0"
- python: pypy3
env: DJANGO_VERSION=">=2.2,<3.0" VERSION_ES=">=5,<6"
- python: pypy3
env: DJANGO_VERSION=">=2.2,<3.0" VERSION_ES=">=2,<3"
- python: pypy3
env: DJANGO_VERSION=">=2.2,<3.0" VERSION_ES=">=1,<2"
- python: pypy3
env: DJANGO_VERSION=">=3.0,<3.1" VERSION_ES=">=5,<6"
- python: pypy3
env: DJANGO_VERSION=">=3.0,<3.1" VERSION_ES=">=2,<3"
- python: pypy3
env: DJANGO_VERSION=">=3.0,<3.1" VERSION_ES=">=1,<2"
- python: 3.5
env: DJANGO_VERSION=">=3.0,<3.1" VERSION_ES=">=1,<2"
- python: 3.5
env: DJANGO_VERSION=">=3.0,<3.1" VERSION_ES=">=2,<3"
- python: 3.5
env: DJANGO_VERSION=">=3.0,<3.1" VERSION_ES=">=5,<6"

notifications:
irc: 'irc.freenode.org#haystack'
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Requirements

Haystack has a relatively easily-met set of requirements.

* Python 2.7+ or Python 3.3+
* Python 3.5+
* A supported version of Django: https://www.djangoproject.com/download/#supported-versions

Additionally, each backend has its own requirements. You should refer to
Expand Down
2 changes: 0 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

from __future__ import absolute_import, division, print_function, unicode_literals

import os
import sys

Expand Down
2 changes: 1 addition & 1 deletion docs/multiple_index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ support. This allows you to talk to several different engines at the same time.
It enables things like master-slave setups, multiple language indexing,
separate indexes for general search & autocomplete as well as other options.

.. _`multiple database support`: http://docs.djangoproject.com/en/1.3/topics/db/multi-db/
.. _`multiple database support`: http://docs.djangoproject.com/en/dev/topics/db/multi-db/


Specifying Available Connections
Expand Down
4 changes: 1 addition & 3 deletions docs/searchindex_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,6 @@ object and write its ``prepare`` method to populate/alter the data any way you
choose. For instance, a (naive) user-created ``GeoPointField`` might look
something like::

from django.utils import six
from haystack import indexes

class GeoPointField(indexes.CharField):
Expand All @@ -341,7 +340,7 @@ something like::
super(GeoPointField, self).__init__(**kwargs)

def prepare(self, obj):
return six.text_type("%s-%s" % (obj.latitude, obj.longitude))
return "%s-%s" % (obj.latitude, obj.longitude)

The ``prepare`` method simply returns the value to be used for that field. It's
entirely possible to include data that's not directly referenced to the object
Expand Down Expand Up @@ -615,4 +614,3 @@ For the impatient::
def index_queryset(self, using=None):
"Used when the entire index for model is updated."
return Note.objects.filter(pub_date__lte=datetime.datetime.now())

2 changes: 1 addition & 1 deletion docs/spatial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Support
=======

You need the latest & greatest of either Solr or Elasticsearch. None of the
other backends (specifially the engines) support this kind of search.
other backends (specifically the engines) support this kind of search.

For Solr_, you'll need at least **v3.5+**. In addition, if you have an existing
install of Haystack & Solr, you'll need to upgrade the schema & reindex your
Expand Down
9 changes: 9 additions & 0 deletions docs/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,16 @@ Example (ElasticSearch 2.x)::
'INDEX_NAME': 'haystack',
},
}

Example (ElasticSearch 5.x)::

HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.elasticsearch5_backend.Elasticsearch5SearchEngine',
'URL': 'http://127.0.0.1:9200/',
'INDEX_NAME': 'haystack',
},
}

Whoosh
~~~~~~
Expand Down
5 changes: 1 addition & 4 deletions example_project/bare_bones_app/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# encoding: utf-8

from __future__ import absolute_import, division, print_function, unicode_literals

import datetime

from django.db import models
Expand All @@ -14,7 +11,7 @@ class Cat(models.Model):
created = models.DateTimeField(default=datetime.datetime.now)
updated = models.DateTimeField(default=datetime.datetime.now)

def __unicode__(self):
def __str__(self):
return self.name

@models.permalink
Expand Down
3 changes: 0 additions & 3 deletions example_project/bare_bones_app/search_indexes.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# encoding: utf-8

from __future__ import absolute_import, division, print_function, unicode_literals

from bare_bones_app.models import Cat

from haystack import indexes
Expand Down
7 changes: 2 additions & 5 deletions example_project/regular_app/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# encoding: utf-8

from __future__ import absolute_import, division, print_function, unicode_literals

import datetime

from django.db import models
Expand All @@ -25,7 +22,7 @@ class Dog(models.Model):
created = models.DateTimeField(default=datetime.datetime.now)
updated = models.DateTimeField(default=datetime.datetime.now)

def __unicode__(self):
def __str__(self):
return self.full_name()

@models.permalink
Expand All @@ -43,5 +40,5 @@ class Toy(models.Model):
dog = models.ForeignKey(Dog, related_name="toys")
name = models.CharField(max_length=60)

def __unicode__(self):
def __str__(self):
return "%s's %s" % (self.dog.name, self.name)
3 changes: 0 additions & 3 deletions example_project/regular_app/search_indexes.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# encoding: utf-8

from __future__ import absolute_import, division, print_function, unicode_literals

from regular_app.models import Dog

from haystack import indexes
Expand Down
3 changes: 0 additions & 3 deletions example_project/settings.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# encoding: utf-8

from __future__ import absolute_import, division, print_function, unicode_literals

import os

from django.conf import settings
Expand Down
5 changes: 1 addition & 4 deletions haystack/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# encoding: utf-8

from __future__ import absolute_import, division, print_function, unicode_literals

from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from pkg_resources import DistributionNotFound, get_distribution, parse_version
Expand All @@ -13,7 +10,7 @@
__author__ = "Daniel Lindsley"

try:
pkg_distribution = get_distribution(__name__)
pkg_distribution = get_distribution("django-haystack")
__version__ = pkg_distribution.version
version_info = pkg_distribution.parsed_version
except DistributionNotFound:
Expand Down
12 changes: 5 additions & 7 deletions haystack/admin.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
# encoding: utf-8

from __future__ import absolute_import, division, print_function, unicode_literals

from django.contrib.admin.options import ModelAdmin, csrf_protect_m
from django.contrib.admin.views.main import SEARCH_VAR, ChangeList
from django.core.exceptions import PermissionDenied
from django.core.paginator import InvalidPage, Paginator
from django.shortcuts import render
from django.utils.encoding import force_text
from django.utils.encoding import force_str
from django.utils.translation import ungettext

from haystack import connections
from haystack.constants import DEFAULT_ALIAS
from haystack.query import SearchQuerySet
from haystack.utils import get_model_ct_tuple


class SearchChangeList(ChangeList):
def __init__(self, **kwargs):
self.haystack_connection = kwargs.pop("haystack_connection", "default")
self.haystack_connection = kwargs.pop("haystack_connection", DEFAULT_ALIAS)
super(SearchChangeList, self).__init__(**kwargs)

def get_results(self, request):
Expand Down Expand Up @@ -61,7 +59,7 @@ def get_results(self, request):

class SearchModelAdminMixin(object):
# haystack connection to use for searching
haystack_connection = "default"
haystack_connection = DEFAULT_ALIAS

@csrf_protect_m
def changelist_view(self, request, extra_context=None):
Expand Down Expand Up @@ -135,7 +133,7 @@ def changelist_view(self, request, extra_context=None):
)

context = {
"module_name": force_text(self.model._meta.verbose_name_plural),
"module_name": force_str(self.model._meta.verbose_name_plural),
"selection_note": selection_note % {"count": len(changelist.result_list)},
"selection_note_all": selection_note_all
% {"total_count": changelist.result_count},
Expand Down
2 changes: 0 additions & 2 deletions haystack/apps.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import unicode_literals

import logging

from django.apps import AppConfig
Expand Down
Loading