Projet

Général

Profil

0001-search-create-and-use-unaccentuated-dictionary-34191.patch

Frédéric Péters, 19 février 2020 10:14

Télécharger (2,53 ko)

Voir les différences:

Subject: [PATCH] search: create and use unaccentuated dictionary (#34191)

 .../apps/search/migrations/0007_french_fts.py | 42 +++++++++++++++++++
 combo/settings.py                             |  2 +-
 2 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 combo/apps/search/migrations/0007_french_fts.py
combo/apps/search/migrations/0007_french_fts.py
1
# -*- coding: utf-8 -*-
2
# Generated by Django 1.11.17 on 2020-02-19 08:20
3
from __future__ import unicode_literals
4

  
5
from django.db import migrations
6
from django.db.migrations.operations.base import Operation
7

  
8

  
9
class TextSearchConfiguration(Operation):
10
    reversible = True
11

  
12
    def state_forwards(self, app_label, state):
13
        pass
14

  
15
    def database_forwards(self, app_label, schema_editor, from_state, to_state):
16
        if schema_editor.connection.vendor != 'postgresql':
17
            return
18
        schema_editor.execute('CREATE EXTENSION IF NOT EXISTS unaccent SCHEMA public')
19
        schema_editor.execute('CREATE TEXT SEARCH CONFIGURATION french_unaccent( COPY = french )')
20
        schema_editor.execute(
21
                'ALTER TEXT SEARCH CONFIGURATION french_unaccent '
22
                'ALTER MAPPING FOR hword, hword_part, word '
23
                'WITH public.unaccent, french_stem')
24

  
25
    def database_backwards(self, app_label, schema_editor, from_state, to_state):
26
        if schema_editor.connection.vendor != 'postgresql':
27
            return
28
        schema_editor.execute('DROP TEXT SEARCH CONFIGURATION french_unaccent')
29

  
30
    def describe(self):
31
        return 'Creates unaccent french text search configuration'
32

  
33

  
34
class Migration(migrations.Migration):
35

  
36
    dependencies = [
37
        ('search', '0006_indexedcell'),
38
    ]
39

  
40
    operations = [
41
        TextSearchConfiguration(),
42
    ]
combo/settings.py
256 256

  
257 257
# search services
258 258
COMBO_SEARCH_SERVICES = {}
259
POSTGRESQL_FTS_SEARCH_CONFIG = 'french'
259
POSTGRESQL_FTS_SEARCH_CONFIG = 'french_unaccent'
260 260

  
261 261
# mapping of payment modes
262 262
LINGO_NO_ONLINE_PAYMENT_REASONS = {}
263
-