diff --git a/CHANGELOG.md b/CHANGELOG.md index 712da4f..ffe032b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.8.4 [unreleased] + +- More flexible highlight options + ## 0.8.3 - Added support for ActiveJob diff --git a/README.md b/README.md index fcbac0b..5a856e2 100644 --- a/README.md +++ b/README.md @@ -553,7 +553,7 @@ Highlight the search query in the results. bands = Band.search "cinema", fields: [:name], highlight: true ``` -**Note:** The `fields` option is required, unless highlight options are given (see below). +**Note:** The `fields` option is required, unless highlight options are given - see below. View the highlighted fields with: @@ -569,22 +569,20 @@ To change the tag, use: Band.search "cinema", fields: [:name], highlight: {tag: ""} ``` -To highlight and search different fields, use: +To highlight and search different fields, use: [master] ```ruby -Band.search "cinema", fields: [:name], highlight: { fields: [:description] } +Band.search "cinema", fields: [:name], highlight: {fields: [:description]} ``` -Additional options, including fragment size, can be specified for each field: +Additional options, including fragment size, can be specified for each field: [master] ```ruby -Band.search "cinema", fields: [:name], highlight: { fields: { name: { fragment_size: 200 } } } +Band.search "cinema", fields: [:name], highlight: {fields: {name: {fragment_size: 200}}} ``` You can find available highlight options in the [Elasticsearch reference](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-highlighting.html#_highlighted_fragments). - - ### Similar Items Find similar items. diff --git a/lib/searchkick/query.rb b/lib/searchkick/query.rb index 8121141..280fab1 100644 --- a/lib/searchkick/query.rb +++ b/lib/searchkick/query.rb @@ -327,7 +327,8 @@ module Searchkick payload[:highlight][:post_tags] = [tag.to_s.gsub(/\A