From 9d3acf660cf5702f57529498ff3cc7f0181c524c Mon Sep 17 00:00:00 2001 From: Matchu Date: Fri, 29 Mar 2013 17:05:14 -0500 Subject: [PATCH] in item queries, ignore name filters that are too small or too large --- app/models/item/search/query.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/models/item/search/query.rb b/app/models/item/search/query.rb index afa84c16..7c2f728b 100644 --- a/app/models/item/search/query.rb +++ b/app/models/item/search/query.rb @@ -61,8 +61,17 @@ class Item # it to each name entry instead. I also feel bad doing this # afterwards, since it's kinda the field's job to return proper flex # params, but that's a refactor for another day. + valid_name_lengths = (3..16) [:_names, :_negative_names].each do |key| if final_flex_params[key] + # This part is also kinda weak. Oh well. Maybe we need + # NGramField that inherits from SetField while also applying + # these restrictions? Remove all name filters that are too + # small or too large. + final_flex_params[key].select! do |name_query| + valid_name_lengths.include?(name_query[:name].length) + end + final_flex_params[key].each do |name_query| name_query[:fields] = locale_entries end