elasticsearch-explain-response 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ade43ddb3bce35fbc76c2f90457646665448a66a
|
4
|
+
data.tar.gz: 58d5df58953bad1dade17dce95826f923a85ebd7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c65535f7eb7d273fc89e41923eee15fc9a3d265e538f70d1c13baed4238365c513e780143518d33cf457923bede9cbee000cdf9e1727df1272a0750f84bac2b8
|
7
|
+
data.tar.gz: c89b690ab7dea90299acba77b7a60717029d42452271d5b1ff41fd178ec9fd5a77262590ee3eb6b9782918e66eb9d796f89c183b925cca0b96a06e4b2004f9d6
|
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "elasticsearch-explain-response"
|
7
|
-
spec.version = "0.0.
|
7
|
+
spec.version = "0.0.5"
|
8
8
|
spec.authors = ["Tomoya Hirano"]
|
9
9
|
spec.email = ["hiranotomoya@gmail.com"]
|
10
10
|
spec.summary = %q{Parser for Elasticserach Explain response}
|
@@ -9,6 +9,7 @@ module Elasticsearch
|
|
9
9
|
def initialize(options = {})
|
10
10
|
disable_colorization if options[:colorize] == false
|
11
11
|
@max = options[:max] || 3
|
12
|
+
@plain_score = options[:plain_score] == true
|
12
13
|
end
|
13
14
|
|
14
15
|
def render(tree)
|
@@ -36,7 +37,7 @@ module Elasticsearch
|
|
36
37
|
end
|
37
38
|
|
38
39
|
def render_score(score)
|
39
|
-
value = if score > 1_000
|
40
|
+
value = if !@plain_score && score > 1_000
|
40
41
|
sprintf("%1.2g", score.round(2))
|
41
42
|
else
|
42
43
|
score.round(2).to_s
|
@@ -19,8 +19,8 @@ module Elasticsearch
|
|
19
19
|
# Show scoring as a simple math formula
|
20
20
|
# @example
|
21
21
|
# "1.0 = (1.0(termFreq=1.0)) x 1.0(idf(2/3)) x 1.0(fieldNorm)"
|
22
|
-
def render_in_line(result,
|
23
|
-
new(result["explanation"],
|
22
|
+
def render_in_line(result, options = {})
|
23
|
+
new(result["explanation"], options).render_in_line
|
24
24
|
end
|
25
25
|
|
26
26
|
# Show scoring with indents
|
@@ -30,17 +30,17 @@ module Elasticsearch
|
|
30
30
|
# 3.35 = 0.2 + 0.93 + 1.29 + 0.93
|
31
31
|
# 54.3 = 54.3 min 3.4028234999999995e+38(maxBoost)
|
32
32
|
# 54.3 = 2.0 x 10.0 x 3.0 x 0.91
|
33
|
-
def render(result,
|
34
|
-
new(result["explanation"],
|
33
|
+
def render(result, options = {})
|
34
|
+
new(result["explanation"], options).render
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
38
|
attr_reader :explain
|
39
39
|
|
40
|
-
def initialize(explain,
|
40
|
+
def initialize(explain, options = {})
|
41
41
|
@explain = explain
|
42
42
|
@indent = 0
|
43
|
-
@renderer = ExplainRenderer.new(
|
43
|
+
@renderer = ExplainRenderer.new({ colorize: true }.merge(options))
|
44
44
|
end
|
45
45
|
|
46
46
|
def render
|
@@ -52,10 +52,11 @@ describe Elasticsearch::API::Response::ExplainResponse do
|
|
52
52
|
|
53
53
|
describe "#render" do
|
54
54
|
let(:response) do
|
55
|
-
described_class.new(fake_response["explanation"], max: max, colorize: false)
|
55
|
+
described_class.new(fake_response["explanation"], max: max, colorize: false, plain_score: plain_score)
|
56
56
|
end
|
57
57
|
|
58
58
|
let(:max) { nil }
|
59
|
+
let(:plain_score) { nil }
|
59
60
|
|
60
61
|
subject do
|
61
62
|
response.render.lines.map(&:rstrip)
|
@@ -87,6 +88,19 @@ describe Elasticsearch::API::Response::ExplainResponse do
|
|
87
88
|
])
|
88
89
|
end
|
89
90
|
end
|
91
|
+
|
92
|
+
context "with plain_score = true" do
|
93
|
+
let(:plain_score) { true }
|
94
|
+
|
95
|
+
it "returns summary of explain in lines" do
|
96
|
+
expect(subject).to match_array([
|
97
|
+
"0.05 = 0.11 x 0.5(coord(1/2)) x 1.0(queryBoost)",
|
98
|
+
" 0.11 = 0.11 min 3.4028235e+38",
|
99
|
+
" 0.11 = 0.11(weight(_all:smith))",
|
100
|
+
" 0.11 = 0.11(score)"
|
101
|
+
])
|
102
|
+
end
|
103
|
+
end
|
90
104
|
end
|
91
105
|
|
92
106
|
describe "colorization" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elasticsearch-explain-response
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomoya Hirano
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|