]> git.parisson.com Git - telemeta.git/commitdiff
Fix contains + ngram_field
authorMathieu <mathieu.boye28@gmail.com>
Sun, 3 Apr 2016 16:11:11 +0000 (18:11 +0200)
committerMathieu <mathieu.boye28@gmail.com>
Sun, 3 Apr 2016 16:11:11 +0000 (18:11 +0200)
app/deploy/app.sh
app/sandbox/settings.py
telemeta/forms/haystack_form.py
telemeta/util/backend.py [new file with mode: 0644]

index ddfba3f749bfc928b827b3dc9135b627695e8847..37b13b9feeb88ae607d3709fcc8cea789dfeed26 100644 (file)
@@ -27,6 +27,9 @@ sh $app/deploy/wait.sh
 # waiting for available database
 python $app/wait.py
 
+#fix contains haystack elasticsearch
+cd /opt/miniconda/lib/python2.7/site-packages/haystack/backends && sed -i "s/'contains': u'%s'/'contains': u'*%s*'/g" elasticsearch_backend.py && cd $app
+
 # django init
 python $manage syncdb --noinput
 python $manage migrate --noinput
@@ -34,6 +37,7 @@ python $manage bower_install -- --allow-root
 python $manage collectstatic --noinput
 python $manage telemeta-create-admin-user
 python $manage telemeta-create-boilerplate
+python $manage rebuild_index --noinput
 
 if [ $DEBUG = "False" ]
 then
index c31f79c783d15d3a874ae7fc9f2c35d4b890f02a..080ccb037718425df0d6e9810ab75460f06a4a85 100644 (file)
@@ -302,7 +302,7 @@ from worker import app
 
 HAYSTACK_CONNECTIONS = {
     'default': {
-        'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
+        'ENGINE': 'telemeta.util.backend.CustomElasticEngine',
         'URL': 'http://search:9200/',
         'INDEX_NAME': 'haystack',
         'INLUDE_SPELLING': True,
index 49017cff5ea6e01a99120055d02888eb342cc118..99a6b74faecb55f14d1330491b98ab5bf453053d 100644 (file)
@@ -27,7 +27,6 @@ from haystack.query import SearchQuerySet
 from datetime import date
 from django.utils.translation import ugettext_lazy as _
 
-
 class HaySearchForm(FacetedSearchForm):
 
     q = forms.CharField(required=False, widget=forms.TextInput(attrs={'class': 'form-control', 'type' : 'text'}))
diff --git a/telemeta/util/backend.py b/telemeta/util/backend.py
new file mode 100644 (file)
index 0000000..8c88253
--- /dev/null
@@ -0,0 +1,13 @@
+from haystack.backends.elasticsearch_backend import *
+
+class CustomElasticBackend(ElasticsearchSearchBackend):
+
+    def setup(self):
+        FIELD_MAPPINGS.get('edge_ngram')['search_analyzer']="standard";
+        FIELD_MAPPINGS.get('ngram')['search_analyzer']="standard";
+        eb = super(CustomElasticBackend, self)
+        eb.DEFAULT_SETTINGS.get('settings').get('analysis').get('filter').get('haystack_ngram')['max_gram']=30
+        eb.setup()
+
+class CustomElasticEngine(ElasticsearchSearchEngine):
+    backend = CustomElasticBackend
\ No newline at end of file