]> git.openstreetmap.org Git - rails.git/commitdiff
Optimise tag searching of ways and relations a bit more...
authorTom Hughes <tom@compton.nu>
Thu, 20 Dec 2007 10:15:45 +0000 (10:15 +0000)
committerTom Hughes <tom@compton.nu>
Thu, 20 Dec 2007 10:15:45 +0000 (10:15 +0000)
app/controllers/search_controller.rb

index 51974455ac113074e3a743d7f82b666c6e653a9b..90ec8fd6a0bf92d2fddb21e924fa5f7cc279a432 100644 (file)
@@ -43,8 +43,8 @@ class SearchController < ApplicationController
       cond_way += [type]
     end
     if value
       cond_way += [type]
     end
     if value
-      sql += ' AND current_way_tags.v=? AND MATCH (current_way_tags.v) AGAINST (?)'
-      cond_way += [value,value]
+      sql += ' AND current_way_tags.v=? AND MATCH (current_way_tags.v) AGAINST (? IN BOOLEAN MODE)'
+      cond_way += [value,'"' + value.sub(/[-+*<>"~()]/, ' ') + '"']
     end
     cond_way = [sql] + cond_way
 
     end
     cond_way = [sql] + cond_way
 
@@ -56,8 +56,8 @@ class SearchController < ApplicationController
       cond_rel += [type]
     end
     if value
       cond_rel += [type]
     end
     if value
-      sql += ' AND current_relation_tags.v=? AND MATCH (current_relation_tags.v) AGAINST (?)'
-      cond_rel += [value,value]
+      sql += ' AND current_relation_tags.v=? AND MATCH (current_relation_tags.v) AGAINST (? IN BOOLEAN MODE)'
+      cond_rel += [value,'"' + value.sub(/[-+*<>"~()]/, ' ') + '"']
     end
     cond_rel = [sql] + cond_rel
 
     end
     cond_rel = [sql] + cond_rel