multi-solr 01.05.00 → 01.06.00
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.
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Filter for booleans
|
|
2
|
+
|
|
3
|
+
class MultiSolr::SolrFilterBoolean < MultiSolr::SolrFilterSimple
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
# Erzeugen des SolR-Query-Strings
|
|
8
|
+
def build_solr_query value
|
|
9
|
+
return nil if value.blank?
|
|
10
|
+
"#{@field_name}:#{to_bool(value)}"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def render_value value
|
|
15
|
+
to_bool(value) ? 'yes' : 'no'
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
private
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def to_bool value
|
|
23
|
+
value && (value == true || value=='1' || value==1 || value=='true')
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
data/lib/multi_solr/version.rb
CHANGED
data/lib/multi_solr.rb
CHANGED
|
@@ -8,6 +8,7 @@ require 'multi_solr/solr_filter_collection'
|
|
|
8
8
|
require 'multi_solr/solr_filter_date'
|
|
9
9
|
require 'multi_solr/solr_filter_date_range'
|
|
10
10
|
require 'multi_solr/solr_filter_free_query'
|
|
11
|
+
require 'multi_solr/solr_filter_boolean'
|
|
11
12
|
require 'multi_solr/filter_value_composite'
|
|
12
13
|
require 'multi_solr/search_request'
|
|
13
14
|
require 'multi_solr/search_result'
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'multi_solr/utils'
|
|
3
|
+
|
|
4
|
+
describe MultiSolr::SolrFilterBoolean do
|
|
5
|
+
|
|
6
|
+
subject{ MultiSolr::SolrFilterBoolean.new('test') }
|
|
7
|
+
|
|
8
|
+
context 'render_value' do
|
|
9
|
+
it "should return 'yes' if value is 1 or true" do
|
|
10
|
+
subject.render_value(1).should == 'yes'
|
|
11
|
+
subject.render_value('1').should == 'yes'
|
|
12
|
+
subject.render_value(true).should == 'yes'
|
|
13
|
+
subject.render_value('1').should == 'yes'
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "should return 'no' if value is 0 or false or nil or blank" do
|
|
17
|
+
subject.render_value(0).should == 'no'
|
|
18
|
+
subject.render_value('0').should == 'no'
|
|
19
|
+
subject.render_value(false).should == 'no'
|
|
20
|
+
subject.render_value('false').should == 'no'
|
|
21
|
+
subject.render_value('').should == 'no'
|
|
22
|
+
subject.render_value(nil).should == 'no'
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
context 'build_solr_query' do
|
|
28
|
+
it "should return fieldnam:true for true value" do
|
|
29
|
+
subject.build_solr_query('1').should == 'test:true'
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "should return fieldnam:false for false value" do
|
|
33
|
+
subject.build_solr_query('0').should == 'test:false'
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: multi-solr
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 15
|
|
5
5
|
prerelease:
|
|
6
6
|
segments:
|
|
7
7
|
- 1
|
|
8
|
-
-
|
|
8
|
+
- 6
|
|
9
9
|
- 0
|
|
10
|
-
version: 01.
|
|
10
|
+
version: 01.06.00
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Bernd Ledig
|
|
@@ -15,7 +15,7 @@ autorequire:
|
|
|
15
15
|
bindir: bin
|
|
16
16
|
cert_chain: []
|
|
17
17
|
|
|
18
|
-
date: 2012-09-
|
|
18
|
+
date: 2012-09-26 00:00:00 Z
|
|
19
19
|
dependencies:
|
|
20
20
|
- !ruby/object:Gem::Dependency
|
|
21
21
|
name: rsolr
|
|
@@ -131,6 +131,7 @@ files:
|
|
|
131
131
|
- lib/multi_solr/search_request.rb
|
|
132
132
|
- lib/multi_solr/search_result.rb
|
|
133
133
|
- lib/multi_solr/single_core_handler.rb
|
|
134
|
+
- lib/multi_solr/solr_filter_boolean.rb
|
|
134
135
|
- lib/multi_solr/solr_filter_collection.rb
|
|
135
136
|
- lib/multi_solr/solr_filter_date.rb
|
|
136
137
|
- lib/multi_solr/solr_filter_date_range.rb
|
|
@@ -144,6 +145,7 @@ files:
|
|
|
144
145
|
- spec/multi_solr/search_request_spec.rb
|
|
145
146
|
- spec/multi_solr/search_result_spec.rb
|
|
146
147
|
- spec/multi_solr/single_core_handler_spec.rb
|
|
148
|
+
- spec/multi_solr/solr_filter_boolean_spec.rb
|
|
147
149
|
- spec/multi_solr/timeline_core_handler_spec.rb
|
|
148
150
|
- spec/multi_solr/utils_spec.rb
|
|
149
151
|
- spec/solr_test_helper.rb
|