Commit dffeca3fe66e85771f1437dc606bdb3645ac7702

Authored by Andrew Kane
1 parent 9f418251

Added unsearchable option

CHANGELOG.md
  1 +## 0.8.5 [unreleased]
  2 +
  3 +- Added `unsearchable` option
  4 +
1 5 ## 0.8.4
2 6  
3 7 - Added `boost_by_distance`
... ...
lib/searchkick/reindex.rb
... ... @@ -288,12 +288,19 @@ module Searchkick
288 288 mapping[field] = field_mapping
289 289 end
290 290  
291   - (options[:locations] || []).each do |field|
  291 + (options[:locations] || []).map(&:to_s).each do |field|
292 292 mapping[field] = {
293 293 type: "geo_point"
294 294 }
295 295 end
296 296  
  297 + (options[:unsearchable] || []).map(&:to_s).each do |field|
  298 + mapping[field] = {
  299 + type: "string",
  300 + index: "no"
  301 + }
  302 + end
  303 +
297 304 mappings = {
298 305 _default_: {
299 306 properties: mapping,
... ...
test/match_test.rb
... ... @@ -153,4 +153,11 @@ class TestMatch < Minitest::Test
153 153 assert_search "to be", ["to be or not to be"]
154 154 end
155 155  
  156 + def test_unsearchable
  157 + store [
  158 + {name: "Unsearchable", description: "Almond"}
  159 + ]
  160 + assert_search "almond", []
  161 + end
  162 +
156 163 end
... ...
test/test_helper.rb
... ... @@ -95,6 +95,7 @@ else
95 95 t.string :color
96 96 t.decimal :latitude, precision: 10, scale: 7
97 97 t.decimal :longitude, precision: 10, scale: 7
  98 + t.text :description
98 99 t.timestamps
99 100 end
100 101  
... ... @@ -146,7 +147,8 @@ class Product
146 147 word_start: [:name],
147 148 word_middle: [:name],
148 149 word_end: [:name],
149   - highlight: [:name]
  150 + highlight: [:name],
  151 + unsearchable: [:description]
150 152  
151 153 attr_accessor :conversions, :user_ids, :aisle
152 154  
... ...