diff --git a/README.md b/README.md index 9bfbcca..61ca248 100644 --- a/README.md +++ b/README.md @@ -437,7 +437,7 @@ gem 'gemoji-parser' And use: ```ruby -Product.search("🍨🍰").emoji(true) +Product.search("🍨🍰").emoji ``` ## Indexing @@ -714,7 +714,7 @@ end Reindex and search with: ```ruby -products = Product.search("peantu butta").suggest(true) +products = Product.search("peantu butta").suggest products.suggestions # ["peanut butter"] ``` @@ -807,7 +807,7 @@ end Highlight the search query in the results. ```ruby -bands = Band.search("cinema").highlight(true) +bands = Band.search("cinema").highlight ``` View the highlighted fields with: @@ -978,7 +978,7 @@ Animal.search("*").type(Dog, Cat) # just cats and dogs 1. The `suggest` option retrieves suggestions from the parent at the moment. ```ruby - Dog.search("airbudd").suggest(true) # suggestions for all animals + Dog.search("airbudd").suggest # suggestions for all animals ``` 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. @@ -987,7 +987,7 @@ Animal.search("*").type(Dog, Cat) # just cats and dogs To help with debugging queries, you can use: ```ruby -Product.search("soap").debug(true) +Product.search("soap").debug ``` This prints useful info to `stdout`. @@ -995,7 +995,7 @@ This prints useful info to `stdout`. See how Elasticsearch scores your queries with: ```ruby -Product.search("soap").explain(true).response +Product.search("soap").explain.response ``` See how Elasticsearch tokenizes your queries with: diff --git a/lib/searchkick/relation.rb b/lib/searchkick/relation.rb index dd11693..b08cbf5 100644 --- a/lib/searchkick/relation.rb +++ b/lib/searchkick/relation.rb @@ -265,11 +265,11 @@ module Searchkick self end - def highlight(value) + def highlight(value = true) spawn.highlight!(value) end - def highlight!(value) + def highlight!(value = true) options[:highlight] = value self end @@ -316,20 +316,20 @@ module Searchkick self end - def debug(value) + def debug(value = true) spawn.debug!(value) end - def debug!(value) + def debug!(value = true) options[:debug] = value self end - def explain(value) + def explain(value = true) spawn.explain!(value) end - def explain!(value) + def explain!(value = true) options[:explain] = value self end @@ -352,15 +352,24 @@ module Searchkick self end - def suggest(value) + def suggest(value = true) spawn.suggest!(value) end - def suggest!(value) + def suggest!(value = true) options[:suggest] = value self end + def emoji(value = true) + spawn.emoji!(value) + end + + def emoji!(value = true) + options[:emoji] = value + self + end + def smart_aggs(value) spawn.smart_aggs!(value) end diff --git a/test/match_test.rb b/test/match_test.rb index 6d7fb6c..e2a8d01 100644 --- a/test/match_test.rb +++ b/test/match_test.rb @@ -296,12 +296,14 @@ class MatchTest < Minitest::Test skip unless defined?(EmojiParser) store_names ["Banana"] assert_search "🍌", ["Banana"], emoji: true + assert_search_relation ["Banana"], Product.search("🍌").emoji end def test_emoji_multiple skip unless defined?(EmojiParser) store_names ["Ice Cream Cake"] assert_search "🍨🍰", ["Ice Cream Cake"], emoji: true + assert_search_relation ["Ice Cream Cake"], Product.search("🍨🍰").emoji end # TODO find better place -- libgit2 0.21.0