inquisitio 1.4.0 → 1.4.1
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 +4 -4
- data/CHANGELOG.md +4 -1
- data/lib/inquisitio/search_url_builder.rb +4 -0
- data/lib/inquisitio/searcher.rb +9 -1
- data/lib/inquisitio/version.rb +1 -1
- data/test/search_url_builder_for_2013_test.rb +6 -0
- data/test/searcher_test.rb +26 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e181e4e047d9916fb1ddac624160bdecfa655023
|
4
|
+
data.tar.gz: 98f870ea6089651bf63186bc4f17279ce01f6c7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ddf6c8e4108945fa0b6114efe04456e6aeff4bebb2c0298b1af1142f20e0d0807b031bf543677f25dcc62d4e04b866ba6fe27c79b1956d424b08e7b1b3a2f492
|
7
|
+
data.tar.gz: 0cfd15e583f38a96f838cdb3547685b82591c1f5f6e01eb6c092d823b98f2a2e86486ee1c436980868cf03a0caeccb815ab85465778363e8c37d863d056a2be3
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
|
+
1.4.1 / 2015-07-15
|
2
|
+
[FEATURE] Searcher now supports #expressions(hash) which maps to expr. expressions in the 2013 api
|
3
|
+
|
1
4
|
1.4.0 / 2015-07-14
|
2
|
-
[FEATURE] Searcher now supports #options() to allow setting of the q.options parameter in the 2013 api
|
5
|
+
[FEATURE] Searcher now supports #options(hash) to allow setting of the q.options parameter in the 2013 api
|
3
6
|
|
4
7
|
1.3.1 / 2015-07-13
|
5
8
|
[BUGFIX] Fixed failing tests
|
@@ -9,6 +9,7 @@ module Inquisitio
|
|
9
9
|
@query = options[:query]
|
10
10
|
@filters = options[:filters] || {}
|
11
11
|
@q_options = options[:q_options] || {}
|
12
|
+
@expressions = options[:expressions] || {}
|
12
13
|
@arguments = options[:arguments] || {}
|
13
14
|
@return_fields = options[:return_fields]
|
14
15
|
@size = options[:size] || Inquisitio.config.default_search_size
|
@@ -23,6 +24,9 @@ module Inquisitio
|
|
23
24
|
components << return_fields_query_string
|
24
25
|
components << arguments
|
25
26
|
components << '&q.options=' + CGI::escape(@q_options.map { |k, v| "{#{k}:#{v}}" }.join('')) unless @q_options.empty?
|
27
|
+
@expressions.each do |name,expression|
|
28
|
+
components << "&expr.#{name}=" + CGI::escape(expression)
|
29
|
+
end
|
26
30
|
components << "&size=#{@size}" unless @arguments[:size]
|
27
31
|
components << "&start=#{@start}" unless @arguments[:start] || @start == 0 || @start == '0'
|
28
32
|
components << '&sort=' + @sort.map { |k, v| "#{k}%20#{v}" }.join(',') unless @sort.empty?
|
data/lib/inquisitio/searcher.rb
CHANGED
@@ -18,7 +18,8 @@ module Inquisitio
|
|
18
18
|
returns: [],
|
19
19
|
with: {},
|
20
20
|
sort: {},
|
21
|
-
q_options: {}
|
21
|
+
q_options: {},
|
22
|
+
expressions: {}
|
22
23
|
}
|
23
24
|
@failed_attempts = 0
|
24
25
|
|
@@ -90,6 +91,12 @@ module Inquisitio
|
|
90
91
|
end
|
91
92
|
end
|
92
93
|
|
94
|
+
def expressions(value)
|
95
|
+
clone do |s|
|
96
|
+
s.params[:expressions] = value
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
93
100
|
def per(value)
|
94
101
|
clone do |s|
|
95
102
|
s.params[:per] = value.to_i
|
@@ -174,6 +181,7 @@ module Inquisitio
|
|
174
181
|
start: params[:per] * (params[:page] - 1),
|
175
182
|
sort: params[:sort],
|
176
183
|
q_options: params[:q_options],
|
184
|
+
expressions: params[:expressions],
|
177
185
|
return_fields: return_fields
|
178
186
|
)
|
179
187
|
end
|
data/lib/inquisitio/version.rb
CHANGED
@@ -112,5 +112,11 @@ module Inquisitio
|
|
112
112
|
expected_url = 'http://my.search-endpoint.com/2013-01-01/search?q=Star+Wars&q.options=%7Bfields%3A%5B%22title%5E2.0%22%2C+%22plot%5E0.5%22%5D%7D&size=10'
|
113
113
|
assert_equal expected_url, url
|
114
114
|
end
|
115
|
+
|
116
|
+
def test_create_search_url_with_expressions
|
117
|
+
url = SearchUrlBuilder.build(query: ['Star Wars'], expressions: {rank1: 'log10(clicks)*_score', rank2: 'cos( _score)'})
|
118
|
+
expected_url = 'http://my.search-endpoint.com/2013-01-01/search?q=Star+Wars&expr.rank1=log10%28clicks%29%2A_score&expr.rank2=cos%28+_score%29&size=10'
|
119
|
+
assert_equal expected_url, url
|
120
|
+
end
|
115
121
|
end
|
116
122
|
end
|
data/test/searcher_test.rb
CHANGED
@@ -406,5 +406,31 @@ module Inquisitio
|
|
406
406
|
refute search_url.include?('q.options='), "search url should not include q.options parameter:\n#{search_url}"
|
407
407
|
end
|
408
408
|
|
409
|
+
def test_should_default_to_no_expressions
|
410
|
+
searcher = Searcher.where('Star Wars')
|
411
|
+
search_url = searcher.send(:search_url)
|
412
|
+
refute search_url =~ /(\?|&)expr\./, "search url should not include any expr. parameters:\n#{search_url}"
|
413
|
+
end
|
414
|
+
|
415
|
+
def test_expressions_should_not_mutate_searcher
|
416
|
+
searcher = Searcher.where('star wars')
|
417
|
+
searcher.expressions(rank1: 'log10(clicks)*_score')
|
418
|
+
search_url = searcher.send(:search_url)
|
419
|
+
refute search_url =~ /(\?|&)expr\.rank1=log10%28clicks%29%2A_score(&|$)/, "search url should not include rank1 expr. parameter:\n#{search_url}"
|
420
|
+
refute search_url =~ /(\?|&)expr\./, "search url should not include any expr. parameters:\n#{search_url}"
|
421
|
+
end
|
422
|
+
|
423
|
+
def test_should_add_one_expression_to_search
|
424
|
+
searcher = Searcher.where('star wars').expressions(rank1: 'log10(clicks)*_score')
|
425
|
+
search_url = searcher.send(:search_url)
|
426
|
+
assert search_url =~ /(\?|&)expr\.rank1=log10%28clicks%29%2A_score(&|$)/, "search url should include expr.rank1 parameter:\n#{search_url}"
|
427
|
+
end
|
428
|
+
|
429
|
+
def test_should_add_more_than_one_expression_to_search
|
430
|
+
searcher = Searcher.where('star wars').expressions(rank1: 'log10(clicks)*_score', rank2: 'cos( _score)')
|
431
|
+
search_url = searcher.send(:search_url)
|
432
|
+
assert search_url =~ /(\?|&)expr\.rank1=log10%28clicks%29%2A_score(&|$)/, "search url should include expr.rank1 parameter:\n#{search_url}"
|
433
|
+
assert search_url =~ /(\?|&)expr\.rank2=cos%28\+_score%29(&|$)/, "search url should include expr.rank1 parameter:\n#{search_url}"
|
434
|
+
end
|
409
435
|
end
|
410
436
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inquisitio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Walker
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2015-07-
|
14
|
+
date: 2015-07-15 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: excon
|