Commit ca4216002a14799975d421d4de11bf5e388dfe5d
1 parent
9248b498
Exists in
relation
and in
1 other branch
Added defaults and emoji
Showing
3 changed files
with
25 additions
and
14 deletions
Show diff stats
README.md
@@ -437,7 +437,7 @@ gem 'gemoji-parser' | @@ -437,7 +437,7 @@ gem 'gemoji-parser' | ||
437 | And use: | 437 | And use: |
438 | 438 | ||
439 | ```ruby | 439 | ```ruby |
440 | -Product.search("๐จ๐ฐ").emoji(true) | 440 | +Product.search("๐จ๐ฐ").emoji |
441 | ``` | 441 | ``` |
442 | 442 | ||
443 | ## Indexing | 443 | ## Indexing |
@@ -714,7 +714,7 @@ end | @@ -714,7 +714,7 @@ end | ||
714 | Reindex and search with: | 714 | Reindex and search with: |
715 | 715 | ||
716 | ```ruby | 716 | ```ruby |
717 | -products = Product.search("peantu butta").suggest(true) | 717 | +products = Product.search("peantu butta").suggest |
718 | products.suggestions # ["peanut butter"] | 718 | products.suggestions # ["peanut butter"] |
719 | ``` | 719 | ``` |
720 | 720 | ||
@@ -807,7 +807,7 @@ end | @@ -807,7 +807,7 @@ end | ||
807 | Highlight the search query in the results. | 807 | Highlight the search query in the results. |
808 | 808 | ||
809 | ```ruby | 809 | ```ruby |
810 | -bands = Band.search("cinema").highlight(true) | 810 | +bands = Band.search("cinema").highlight |
811 | ``` | 811 | ``` |
812 | 812 | ||
813 | View the highlighted fields with: | 813 | View the highlighted fields with: |
@@ -978,7 +978,7 @@ Animal.search("*").type(Dog, Cat) # just cats and dogs | @@ -978,7 +978,7 @@ Animal.search("*").type(Dog, Cat) # just cats and dogs | ||
978 | 1. The `suggest` option retrieves suggestions from the parent at the moment. | 978 | 1. The `suggest` option retrieves suggestions from the parent at the moment. |
979 | 979 | ||
980 | ```ruby | 980 | ```ruby |
981 | - Dog.search("airbudd").suggest(true) # suggestions for all animals | 981 | + Dog.search("airbudd").suggest # suggestions for all animals |
982 | ``` | 982 | ``` |
983 | 2. This relies on a `type` field that is automatically added to the indexed document. Be wary of defining your own `type` field in `search_data`, as it will take precedence. | 983 | 2. This relies on a `type` field that is automatically added to the indexed document. Be wary of defining your own `type` field in `search_data`, as it will take precedence. |
984 | 984 | ||
@@ -987,7 +987,7 @@ Animal.search("*").type(Dog, Cat) # just cats and dogs | @@ -987,7 +987,7 @@ Animal.search("*").type(Dog, Cat) # just cats and dogs | ||
987 | To help with debugging queries, you can use: | 987 | To help with debugging queries, you can use: |
988 | 988 | ||
989 | ```ruby | 989 | ```ruby |
990 | -Product.search("soap").debug(true) | 990 | +Product.search("soap").debug |
991 | ``` | 991 | ``` |
992 | 992 | ||
993 | This prints useful info to `stdout`. | 993 | This prints useful info to `stdout`. |
@@ -995,7 +995,7 @@ This prints useful info to `stdout`. | @@ -995,7 +995,7 @@ This prints useful info to `stdout`. | ||
995 | See how Elasticsearch scores your queries with: | 995 | See how Elasticsearch scores your queries with: |
996 | 996 | ||
997 | ```ruby | 997 | ```ruby |
998 | -Product.search("soap").explain(true).response | 998 | +Product.search("soap").explain.response |
999 | ``` | 999 | ``` |
1000 | 1000 | ||
1001 | See how Elasticsearch tokenizes your queries with: | 1001 | See how Elasticsearch tokenizes your queries with: |
lib/searchkick/relation.rb
@@ -265,11 +265,11 @@ module Searchkick | @@ -265,11 +265,11 @@ module Searchkick | ||
265 | self | 265 | self |
266 | end | 266 | end |
267 | 267 | ||
268 | - def highlight(value) | 268 | + def highlight(value = true) |
269 | spawn.highlight!(value) | 269 | spawn.highlight!(value) |
270 | end | 270 | end |
271 | 271 | ||
272 | - def highlight!(value) | 272 | + def highlight!(value = true) |
273 | options[:highlight] = value | 273 | options[:highlight] = value |
274 | self | 274 | self |
275 | end | 275 | end |
@@ -316,20 +316,20 @@ module Searchkick | @@ -316,20 +316,20 @@ module Searchkick | ||
316 | self | 316 | self |
317 | end | 317 | end |
318 | 318 | ||
319 | - def debug(value) | 319 | + def debug(value = true) |
320 | spawn.debug!(value) | 320 | spawn.debug!(value) |
321 | end | 321 | end |
322 | 322 | ||
323 | - def debug!(value) | 323 | + def debug!(value = true) |
324 | options[:debug] = value | 324 | options[:debug] = value |
325 | self | 325 | self |
326 | end | 326 | end |
327 | 327 | ||
328 | - def explain(value) | 328 | + def explain(value = true) |
329 | spawn.explain!(value) | 329 | spawn.explain!(value) |
330 | end | 330 | end |
331 | 331 | ||
332 | - def explain!(value) | 332 | + def explain!(value = true) |
333 | options[:explain] = value | 333 | options[:explain] = value |
334 | self | 334 | self |
335 | end | 335 | end |
@@ -352,15 +352,24 @@ module Searchkick | @@ -352,15 +352,24 @@ module Searchkick | ||
352 | self | 352 | self |
353 | end | 353 | end |
354 | 354 | ||
355 | - def suggest(value) | 355 | + def suggest(value = true) |
356 | spawn.suggest!(value) | 356 | spawn.suggest!(value) |
357 | end | 357 | end |
358 | 358 | ||
359 | - def suggest!(value) | 359 | + def suggest!(value = true) |
360 | options[:suggest] = value | 360 | options[:suggest] = value |
361 | self | 361 | self |
362 | end | 362 | end |
363 | 363 | ||
364 | + def emoji(value = true) | ||
365 | + spawn.emoji!(value) | ||
366 | + end | ||
367 | + | ||
368 | + def emoji!(value = true) | ||
369 | + options[:emoji] = value | ||
370 | + self | ||
371 | + end | ||
372 | + | ||
364 | def smart_aggs(value) | 373 | def smart_aggs(value) |
365 | spawn.smart_aggs!(value) | 374 | spawn.smart_aggs!(value) |
366 | end | 375 | end |
test/match_test.rb
@@ -296,12 +296,14 @@ class MatchTest < Minitest::Test | @@ -296,12 +296,14 @@ class MatchTest < Minitest::Test | ||
296 | skip unless defined?(EmojiParser) | 296 | skip unless defined?(EmojiParser) |
297 | store_names ["Banana"] | 297 | store_names ["Banana"] |
298 | assert_search "๐", ["Banana"], emoji: true | 298 | assert_search "๐", ["Banana"], emoji: true |
299 | + assert_search_relation ["Banana"], Product.search("๐").emoji | ||
299 | end | 300 | end |
300 | 301 | ||
301 | def test_emoji_multiple | 302 | def test_emoji_multiple |
302 | skip unless defined?(EmojiParser) | 303 | skip unless defined?(EmojiParser) |
303 | store_names ["Ice Cream Cake"] | 304 | store_names ["Ice Cream Cake"] |
304 | assert_search "๐จ๐ฐ", ["Ice Cream Cake"], emoji: true | 305 | assert_search "๐จ๐ฐ", ["Ice Cream Cake"], emoji: true |
306 | + assert_search_relation ["Ice Cream Cake"], Product.search("๐จ๐ฐ").emoji | ||
305 | end | 307 | end |
306 | 308 | ||
307 | # TODO find better place | 309 | # TODO find better place |