]> git.parisson.com Git - telemeta.git/commitdiff
Revue du mapping ES (utilisation startswith +coherent)
authormathieu <mathieu.boye28@gmail.com>
Tue, 26 Apr 2016 15:10:36 +0000 (17:10 +0200)
committermathieu <mathieu.boye28@gmail.com>
Tue, 26 Apr 2016 15:10:36 +0000 (17:10 +0200)
env/debug.env
telemeta/forms/haystack_form.py
telemeta/util/backend.py
telemeta/views/search.py

index a19e34770877c2c4104fc1cee497ee521afd6e88..7a9fbbcc2efd668f22107e8e9316a87bd0755b0f 100644 (file)
@@ -18,4 +18,4 @@ BROKER_URL=redis://broker:6379/0
 # If this is True, all tasks will be executed locally by blocking until the task returns.
 CELERY_ALWAYS_EAGER=False
 
-REINDEX=False
+REINDEX=True
index adb39e000a93dd45d64ef3249db921b9cc30ea8d..ceace2d8657c7e8ee6f23771381f21386237fb29 100644 (file)
@@ -193,13 +193,13 @@ class HayAdvanceForm(SearchForm):
             return self.no_query_found()
 
         if self.cleaned_data.get('q'):
-            sqs = sqs.filter(title__contains=self.cleaned_data['q'])
+            sqs = sqs.filter(title__startswith=self.cleaned_data['q'])
 
         if self.cleaned_data.get('code'):
             sqs = sqs.filter(code__contains=self.cleaned_data['code'])
 
         if self.cleaned_data.get('location'):
-            sqs = sqs.filter(location_principal__contains=self.cleaned_data['location']).filter_or(location_relation__contains=self.cleaned_data['location'])
+            sqs = sqs.filter(location_principal__startswith=self.cleaned_data['location']).filter_or(location_relation__startswith=self.cleaned_data['location'])
 
         if self.cleaned_data['ethnic_group']:
             if self.cleaned_data.get('ethnic_group') != '':
index 489a61d169413a21b90c11e10032df62c1a6e7b9..374bd19c566b612a31ef12875e84f0ad1c7f272b 100644 (file)
@@ -5,11 +5,10 @@ from haystack.backends.elasticsearch_backend import *
 class CustomElasticBackend(ElasticsearchSearchBackend):
 
     def setup(self):
-
-        DEFAULT_FIELD_MAPPING['analyzer']='space_lower_analyzer'
+        DEFAULT_FIELD_MAPPING['analyzer']='snowball_asciifolding_analyzer'
         eb = super(CustomElasticBackend, self)
-        eb.DEFAULT_SETTINGS.get('settings').get('analysis').get('analyzer')['space_lower_analyzer']=\
-            {"type": "custom", "tokenizer": "whitespace", "filter": ["lowercase", "asciifolding"]}
+        eb.DEFAULT_SETTINGS.get('settings').get('analysis').get('analyzer')['snowball_asciifolding_analyzer']=\
+            {"type": "custom", "tokenizer": "letter", "filter": ["lowercase", "stop",  "asciifolding"]}
         eb.setup()
 
 
@@ -29,5 +28,5 @@ class CustomElasticSearchQuery(ElasticsearchSearchQuery):
 
 class CustomElasticEngine(ElasticsearchSearchEngine):
     backend = CustomElasticBackend
-    query = CustomElasticSearchQuery#
+    query = CustomElasticSearchQuery
 
index 260111833e9288a6f2a8a1b72649dfdf7712e3aa..10801655b932dd6b3787f8656cd4eec2f950e10b 100644 (file)
@@ -177,7 +177,7 @@ def autocomplete(request):
         suggestions = [result.code for result in sqs]
 
     elif request.GET.get('attr', '') == "collectors":
-        sqs = sqs.filter(collectors__contains=request.GET.get('q', ''))[:10]
+        sqs = sqs.filter(collectors__startswith=request.GET.get('q', ''))[:10]
         suggestions = [result.collectors for result in sqs]
     else:
         suggestions = []
@@ -252,5 +252,5 @@ class BooleanSearchView(object):
 
 
 
-class Erreur(Exception):
-    pass
\ No newline at end of file
+class Erreur(Exception):#
+    pass#
\ No newline at end of file