From eff57eeca98b2adf22cf877b540e0cc5e64668e5 Mon Sep 17 00:00:00 2001 From: David Blackmon Date: Thu, 14 May 2020 10:07:40 -0400 Subject: [PATCH 1/4] expose matched_queries property on hits --- lib/elasticity/base_document.rb | 2 +- lib/elasticity/index_mapper.rb | 1 + spec/functional/search_spec.rb | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/elasticity/base_document.rb b/lib/elasticity/base_document.rb index 594b16f..a945d4c 100644 --- a/lib/elasticity/base_document.rb +++ b/lib/elasticity/base_document.rb @@ -12,7 +12,7 @@ def self.configure(&block) end # Define common attributes for all documents - attr_accessor :_id, :highlighted, :_score, :sort, :_explanation, :highlighted_attrs + attr_accessor :_id, :highlighted, :_score, :sort, :_explanation, :highlighted_attrs, :matched_queries def attributes=(attributes) attributes.each do |attr, value| diff --git a/lib/elasticity/index_mapper.rb b/lib/elasticity/index_mapper.rb index 76e7af9..a62eb7d 100644 --- a/lib/elasticity/index_mapper.rb +++ b/lib/elasticity/index_mapper.rb @@ -150,6 +150,7 @@ def map_hit(hit) attrs.merge!(_score: hit["_score"]) attrs.merge!(sort: hit["sort"]) attrs.merge!(hit["_source"]) if hit["_source"] + attrs.merge!(matched_queries: hit["matched_queries"]) if hit["matched_queries"] highlighted = nil diff --git a/spec/functional/search_spec.rb b/spec/functional/search_spec.rb index 9a946ad..7d620b7 100644 --- a/spec/functional/search_spec.rb +++ b/spec/functional/search_spec.rb @@ -76,6 +76,25 @@ def get_explanations(results) end end + describe "matched_queries" do + it "returns a list of named queries that were matched on the result" do + query = { + query: { + match: { + description: { + query: "old", + _name: "description_query" + } + } + } + } + results = CatDoc.search(query).search_results + expect(results.size).to eq(1) + result = results.first + expect(result.matched_queries).to eq(["description_query"]) + end + end + describe "highlight" do it "is nil when the highlight does not return" do results = CatDoc.search({}).search_results From 4c3135fd3fb3261799c6fd516b4534b276117f7e Mon Sep 17 00:00:00 2001 From: David Blackmon Date: Thu, 14 May 2020 10:10:12 -0400 Subject: [PATCH 2/4] bump version --- CHANGELOG.md | 4 ++++ Gemfile.lock | 2 +- lib/elasticity/version.rb | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 070fce8..320f55d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] +## [0.13.4.dblackmon.0] - 2020-05-30 +### Changed +- expose 'matched_queries' property + ## [0.13.3] - 2020-01-30 ### Changed - Release on RubyGems using gem-publisher CircleCI Orb diff --git a/Gemfile.lock b/Gemfile.lock index 9f308c6..e9b3e18 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - es-elasticity (0.13.3) + es-elasticity (0.13.4.dblackmon.0) activemodel (>= 4.0.0, < 6) activerecord (>= 4.0.0, < 6) activesupport (>= 4.0.0, < 6) diff --git a/lib/elasticity/version.rb b/lib/elasticity/version.rb index 025925e..52b7270 100644 --- a/lib/elasticity/version.rb +++ b/lib/elasticity/version.rb @@ -1,3 +1,3 @@ module Elasticity - VERSION = "0.13.3" + VERSION = "0.13.4.dblackmon.0" end From 475bc195fafa85312584de844f8211bc5c218295 Mon Sep 17 00:00:00 2001 From: David Blackmon Date: Thu, 14 May 2020 13:45:55 -0400 Subject: [PATCH 3/4] bump version again --- CHANGELOG.md | 2 +- Gemfile.lock | 2 +- lib/elasticity/version.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 320f55d..235d04e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] -## [0.13.4.dblackmon.0] - 2020-05-30 +## [0.13.4.dblackmon.1] - 2020-05-30 ### Changed - expose 'matched_queries' property diff --git a/Gemfile.lock b/Gemfile.lock index e9b3e18..99c9e67 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - es-elasticity (0.13.4.dblackmon.0) + es-elasticity (0.13.4.dblackmon.1) activemodel (>= 4.0.0, < 6) activerecord (>= 4.0.0, < 6) activesupport (>= 4.0.0, < 6) diff --git a/lib/elasticity/version.rb b/lib/elasticity/version.rb index 52b7270..3efd7d6 100644 --- a/lib/elasticity/version.rb +++ b/lib/elasticity/version.rb @@ -1,3 +1,3 @@ module Elasticity - VERSION = "0.13.4.dblackmon.0" + VERSION = "0.13.4.dblackmon.1" end From de2f543993301096b586adfa400aa95691fff29f Mon Sep 17 00:00:00 2001 From: David Blackmon Date: Thu, 28 May 2020 14:02:53 -0400 Subject: [PATCH 4/4] bump version to remove pre tag --- CHANGELOG.md | 2 +- Gemfile.lock | 2 +- lib/elasticity/version.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad4cebf..b68527a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] -## [0.13.5.dblackmon.1] - 2020-05-21 +## [0.13.5] - 2020-05-21 ### Changed - expose 'matched_queries' property diff --git a/Gemfile.lock b/Gemfile.lock index 75f2b40..eae2e4e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - es-elasticity (0.13.5.dblackmon.1) + es-elasticity (0.13.5) activemodel (>= 4.0.0, < 7) activerecord (>= 4.0.0, < 7) activesupport (>= 4.0.0, < 7) diff --git a/lib/elasticity/version.rb b/lib/elasticity/version.rb index 855b1a5..0962e42 100644 --- a/lib/elasticity/version.rb +++ b/lib/elasticity/version.rb @@ -1,3 +1,3 @@ module Elasticity - VERSION = "0.13.5.dblackmon.1" + VERSION = "0.13.5" end