Browse Source

updated lu_text_match

tags/v0.1.1
Robin Thoni 7 years ago
parent
commit
b09e55ff5f
1 changed files with 9 additions and 1 deletions
  1. 9
    1
      postgresql/docker-entrypoint-initdb.d/01_luticate2_utils.sql

+ 9
- 1
postgresql/docker-entrypoint-initdb.d/01_luticate2_utils.sql View File

84
 return NEW;
84
 return NEW;
85
 END$$;
85
 END$$;
86
 
86
 
87
+--
88
+-- Name: lu_text_match_prepare(text); Type: FUNCTION; Schema: public; Owner: dev
89
+--
90
+
91
+CREATE FUNCTION lu_text_match_prepare(data text) RETURNS text
92
+    LANGUAGE sql
93
+        AS $$SELECT regexp_replace(unaccent(data), '[^a-zA-Z0-9]+', ' ', 'g')$$;
94
+
87
 --
95
 --
88
 -- Name: lu_text_match(text, text); Type: FUNCTION; Schema: public; 
96
 -- Name: lu_text_match(text, text); Type: FUNCTION; Schema: public; 
89
 --
97
 --
90
 
98
 
91
 CREATE FUNCTION lu_text_match(query text, data text) RETURNS boolean
99
 CREATE FUNCTION lu_text_match(query text, data text) RETURNS boolean
92
     LANGUAGE sql
100
     LANGUAGE sql
93
-    AS $$SELECT unaccent(data) ILIKE  ('%' || unaccent(query) || '%') AS result$$;
101
+    AS $$SELECT lu_text_match_prepare(data) ILIKE  ('%' || lu_text_match_prepare(query) || '%') AS result$$;
94
 
102
 
95
 --
103
 --
96
 -- Name: lu_texts_match(text, text[]); Type: FUNCTION; Schema: public; 
104
 -- Name: lu_texts_match(text, text[]); Type: FUNCTION; Schema: public; 

Loading…
Cancel
Save