active_triples-solrizer 0.3.0

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,179 @@
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+ <config>
3
+ <!-- NOTE: various comments and unused configuration possibilities have been purged
4
+ from this file. Please refer to http://wiki.apache.org/solr/SolrConfigXml,
5
+ as well as the default solrconfig file included with Solr -->
6
+
7
+ <abortOnConfigurationError>${solr.abortOnConfigurationError:true}</abortOnConfigurationError>
8
+
9
+ <luceneMatchVersion>4.9</luceneMatchVersion>
10
+
11
+ <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.StandardDirectoryFactory}"/>
12
+
13
+ <!-- solr lib dirs -->
14
+ <lib dir="../lib/contrib/analysis-extras/lib" />
15
+ <lib dir="../lib/contrib/analysis-extras/lucene-libs" />
16
+
17
+ <dataDir>${solr.data.dir:}</dataDir>
18
+
19
+ <updateHandler class="solr.DirectUpdateHandler2">
20
+
21
+ <updateLog>
22
+ <str name="dir">${solr.ulog.dir:}</str>
23
+ </updateLog>
24
+
25
+ <autoCommit>
26
+ <maxTime>${solr.autoCommit.maxTime:15000}</maxTime>
27
+ <openSearcher>false</openSearcher>
28
+ </autoCommit>
29
+
30
+ <autoSoftCommit>
31
+ <maxTime>${solr.autoSoftCommit.maxTime:-1}</maxTime>
32
+ </autoSoftCommit>
33
+
34
+ </updateHandler>
35
+
36
+ <requestHandler name="search" class="solr.SearchHandler" default="true">
37
+ <!-- default values for query parameters can be specified, these
38
+ will be overridden by parameters in the request
39
+ -->
40
+ <lst name="defaults">
41
+ <str name="defType">edismax</str>
42
+ <str name="echoParams">explicit</str>
43
+ <str name="q.alt">*:*</str>
44
+ <str name="mm">2&lt;-1 5&lt;-2 6&lt;90%</str>
45
+ <int name="qs">1</int>
46
+ <int name="ps">2</int>
47
+ <float name="tie">0.01</float>
48
+ <!-- this qf and pf are used by default, if not otherwise specified by
49
+ client. The default blacklight_config will use these for the
50
+ "keywords" search. See the author_qf/author_pf, title_qf, etc
51
+ below, which the default blacklight_config will specify for
52
+ those searches. You may also be interested in:
53
+ http://wiki.apache.org/solr/LocalParams
54
+ -->
55
+ <str name="qf">
56
+ id
57
+ all_text_timv
58
+ active_fedora_model_ssi
59
+ object_type_si
60
+ </str>
61
+ <str name="pf">
62
+ all_text_timv^10
63
+ </str>
64
+
65
+ <str name="author_qf">
66
+ </str>
67
+ <str name="author_pf">
68
+ </str>
69
+ <str name="title_qf">
70
+ </str>
71
+ <str name="title_pf">
72
+ </str>
73
+ <str name="subject_qf">
74
+ </str>
75
+ <str name="subject_pf">
76
+ </str>
77
+
78
+ <str name="fl">
79
+ *,
80
+ score
81
+ </str>
82
+
83
+ <str name="facet">true</str>
84
+ <str name="facet.mincount">1</str>
85
+ <str name="facet.limit">10</str>
86
+ <str name="facet.field">active_fedora_model_ssi</str>
87
+ <str name="facet.field">object_type_si</str>
88
+
89
+ <str name="spellcheck">true</str>
90
+ <str name="spellcheck.dictionary">default</str>
91
+ <str name="spellcheck.onlyMorePopular">true</str>
92
+ <str name="spellcheck.extendedResults">true</str>
93
+ <str name="spellcheck.collate">false</str>
94
+ <str name="spellcheck.count">5</str>
95
+
96
+ </lst>
97
+ <arr name="last-components">
98
+ <str>spellcheck</str>
99
+ </arr>
100
+ </requestHandler>
101
+
102
+ <requestHandler name="permissions" class="solr.SearchHandler" >
103
+ <lst name="defaults">
104
+ <str name="facet">off</str>
105
+ <str name="echoParams">all</str>
106
+ <str name="rows">1</str>
107
+ <str name="q">{!raw f=id v=$id}</str> <!-- use id=666 instead of q=id:666 -->
108
+ <str name="fl">
109
+ id,
110
+ access_ssim,
111
+ discover_access_group_ssim,discover_access_person_ssim,
112
+ read_access_group_ssim,read_access_person_ssim,
113
+ edit_access_group_ssim,edit_access_person_ssim,
114
+ depositor_ti,
115
+ embargo_release_date_dtsi
116
+ inheritable_access_ssim,
117
+ inheritable_discover_access_group_ssim,inheritable_discover_access_person_ssim,
118
+ inheritable_read_access_group_ssim,inheritable_read_access_person_ssim,
119
+ inheritable_edit_access_group_ssim,inheritable_edit_access_person_ssim,
120
+ inheritable_embargo_release_date_dtsi
121
+ </str>
122
+ </lst>
123
+ </requestHandler>
124
+
125
+ <requestHandler name="standard" class="solr.SearchHandler">
126
+ <lst name="defaults">
127
+ <str name="echoParams">explicit</str>
128
+ <str name="defType">lucene</str>
129
+ </lst>
130
+ </requestHandler>
131
+
132
+ <!-- for requests to get a single document; use id=666 instead of q=id:666 -->
133
+ <requestHandler name="document" class="solr.SearchHandler" >
134
+ <lst name="defaults">
135
+ <str name="echoParams">all</str>
136
+ <str name="fl">*</str>
137
+ <str name="rows">1</str>
138
+ <str name="q">{!raw f=id v=$id}</str> <!-- use id=666 instead of q=id:666 -->
139
+ </lst>
140
+ </requestHandler>
141
+
142
+ <searchComponent name="spellcheck" class="solr.SpellCheckComponent">
143
+ <str name="queryAnalyzerFieldType">textSpell</str>
144
+ <!-- Multiple "Spell Checkers" can be declared and used by this component
145
+ (e.g. for title_spell field)
146
+ -->
147
+ <lst name="spellchecker">
148
+ <str name="name">default</str>
149
+ <str name="field">spell</str>
150
+ <str name="spellcheckIndexDir">./spell</str>
151
+ <str name="buildOnOptimize">true</str>
152
+ </lst>
153
+ </searchComponent>
154
+
155
+ <requestHandler name="/replication" class="solr.ReplicationHandler" startup="lazy" />
156
+
157
+ <requestDispatcher handleSelect="true" >
158
+ <requestParsers enableRemoteStreaming="true" multipartUploadLimitInKB="2048" />
159
+ </requestDispatcher>
160
+
161
+ <requestHandler name="/analysis/field" startup="lazy" class="solr.FieldAnalysisRequestHandler" />
162
+ <requestHandler name="/update" class="solr.UpdateRequestHandler" />
163
+ <requestHandler name="/admin/" class="org.apache.solr.handler.admin.AdminHandlers" />
164
+
165
+ <requestHandler name="/admin/ping" class="solr.PingRequestHandler">
166
+ <lst name="invariants">
167
+ <str name="q">solrpingquery</str>
168
+ </lst>
169
+ <lst name="defaults">
170
+ <str name="echoParams">all</str>
171
+ </lst>
172
+ </requestHandler>
173
+
174
+ <!-- config for the admin interface -->
175
+ <admin>
176
+ <defaultQuery>search</defaultQuery>
177
+ </admin>
178
+
179
+ </config>
@@ -0,0 +1,79 @@
1
+ require 'spec_helper'
2
+ require 'support/dummy_resource.rb'
3
+
4
+ describe ActiveTriples::Solrizer::SolrService do
5
+
6
+ describe "#generate_solr_document" do
7
+ include_context "shared dummy resource class"
8
+
9
+ context "when small number of properties" do
10
+ it "should produce solr doc with all indexed properties" do
11
+ expect( ActiveTriples::Solrizer::IndexingService.new(dr_short_all_values).generate_solr_document ).to eq expected_solr_doc_short_all_values
12
+ end
13
+
14
+ it "should produce solr doc with only properties with values indexed" do
15
+ expect( ActiveTriples::Solrizer::IndexingService.new(dr_short_partial_values).generate_solr_document ).to eq expected_solr_doc_short_partial_values
16
+ end
17
+ end
18
+
19
+ context "when all properties indexed" do
20
+ it "should produce solr doc with all indexed properties" do
21
+ expect( ActiveTriples::Solrizer::IndexingService.new(dr_indexed).generate_solr_document ).to eq expected_solr_doc_indexed
22
+ end
23
+ end
24
+
25
+ context "when all properties stored" do
26
+ it "should produce solr doc with all stored properties" do
27
+ expect( ActiveTriples::Solrizer::IndexingService.new(dr_stored).generate_solr_document ).to eq expected_solr_doc_stored
28
+ end
29
+ end
30
+
31
+ context "when all properties stored and indexed" do
32
+ it "should produce solr doc with all stored indexed properties" do
33
+ expect( ActiveTriples::Solrizer::IndexingService.new(dr_stored_indexed).generate_solr_document ).to eq expected_solr_doc_stored_indexed
34
+ end
35
+ end
36
+
37
+ context "when all properties indexed and multi-valued" do
38
+ it "should produce solr doc with all indexed properties" do
39
+ expect( ActiveTriples::Solrizer::IndexingService.new(dr_indexed_multi).generate_solr_document ).to eq expected_solr_doc_indexed_multi
40
+ end
41
+ end
42
+
43
+ context "when all properties stored and multi-valued" do
44
+ it "should produce solr doc with all stored properties" do
45
+ expect( ActiveTriples::Solrizer::IndexingService.new(dr_stored_multi).generate_solr_document ).to eq expected_solr_doc_stored_multi
46
+ end
47
+ end
48
+
49
+ context "when all properties stored and indexed and multi-valued" do
50
+ it "should produce solr doc with all stored indexed properties" do
51
+ expect( ActiveTriples::Solrizer::IndexingService.new(dr_stored_indexed_multi).generate_solr_document ).to eq expected_solr_doc_stored_indexed_multi
52
+ end
53
+ end
54
+
55
+ context "when all properties indexed and range" do
56
+ it "should produce solr doc with all indexed properties optimized for range" do
57
+ expect( ActiveTriples::Solrizer::IndexingService.new(dr_indexed_range).generate_solr_document ).to eq expected_solr_doc_indexed_range
58
+ end
59
+ end
60
+
61
+ context "when all properties indexed and sortable" do
62
+ it "should produce solr doc with all indexed properties set up for sorting" do
63
+ expect( ActiveTriples::Solrizer::IndexingService.new(dr_indexed_sort).generate_solr_document ).to eq expected_solr_doc_indexed_sort
64
+ end
65
+ end
66
+
67
+ context "when all properties indexed and vectored" do
68
+ it "should produce solr doc with all indexed properties and text fields vectored" do
69
+ expect( ActiveTriples::Solrizer::IndexingService.new(dr_indexed_vector).generate_solr_document ).to eq expected_solr_doc_indexed_vector
70
+ end
71
+ end
72
+
73
+ context "when all properties indexed and guessing the type" do
74
+ it "should produce solr doc with all indexed properties with appropriate types" do
75
+ expect( ActiveTriples::Solrizer::IndexingService.new(dr_indexed_guess).generate_solr_document ).to eq expected_solr_doc_indexed_guess
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,149 @@
1
+ require 'spec_helper'
2
+ require 'support/dummy_resource.rb'
3
+
4
+ describe ActiveTriples::Solrizer::ProfileIndexingService do
5
+ include_context "shared dummy resource class"
6
+
7
+ describe "#export" do
8
+
9
+ context "when small number of properties" do
10
+ it "should produce object profile holding serialization of the resource" do
11
+ expect( ActiveTriples::Solrizer::ProfileIndexingService.new(dr_short_all_values).export ).to eq expected_object_profile_short_all_values
12
+ end
13
+
14
+ it "should produce object profile holding serialization of the resource" do
15
+ expect( ActiveTriples::Solrizer::ProfileIndexingService.new(dr_short_partial_values).export ).to eq expected_object_profile_short_partial_values
16
+ end
17
+ end
18
+
19
+ context "when all properties indexed" do
20
+ it "should produce object profile holding serialization of the resource" do
21
+ expect( ActiveTriples::Solrizer::ProfileIndexingService.new(dr_indexed).export ).to eq expected_object_profile_indexed
22
+ end
23
+ end
24
+
25
+ context "when all properties stored" do
26
+ it "should produce object profile holding serialization of the resource" do
27
+ expect( ActiveTriples::Solrizer::ProfileIndexingService.new(dr_stored).export ).to eq expected_object_profile_stored
28
+ end
29
+ end
30
+
31
+ context "when all properties stored and indexed" do
32
+ it "should produce object profile holding serialization of the resource" do
33
+ expect( ActiveTriples::Solrizer::ProfileIndexingService.new(dr_stored_indexed).export ).to eq expected_object_profile_stored_indexed
34
+ end
35
+ end
36
+
37
+ context "when all properties indexed and multi-valued" do
38
+ it "should produce object profile holding serialization of the resource" do
39
+ expect( ActiveTriples::Solrizer::ProfileIndexingService.new(dr_indexed_multi).export ).to eq expected_object_profile_indexed_multi
40
+ end
41
+ end
42
+
43
+ context "when all properties stored and multi-valued" do
44
+ it "should produce object profile holding serialization of the resource" do
45
+ expect( ActiveTriples::Solrizer::ProfileIndexingService.new(dr_stored_multi).export ).to eq expected_object_profile_stored_multi
46
+ end
47
+ end
48
+
49
+ context "when all properties stored and indexed and multi-valued" do
50
+ it "should produce object profile holding serialization of the resource" do
51
+ expect( ActiveTriples::Solrizer::ProfileIndexingService.new(dr_stored_indexed_multi).export ).to eq expected_object_profile_stored_indexed_multi
52
+ end
53
+ end
54
+
55
+ context "when all properties indexed and range" do
56
+ it "should produce object profile holding serialization of the resource" do
57
+ expect( ActiveTriples::Solrizer::ProfileIndexingService.new(dr_indexed_range).export ).to eq expected_object_profile_indexed_range
58
+ end
59
+ end
60
+
61
+ context "when all properties indexed and sortable" do
62
+ it "should produce object profile holding serialization of the resource" do
63
+ expect( ActiveTriples::Solrizer::ProfileIndexingService.new(dr_indexed_sort).export ).to eq expected_object_profile_indexed_sort
64
+ end
65
+ end
66
+
67
+ context "when all properties indexed and vectored" do
68
+ it "should produce object profile holding serialization of the resource" do
69
+ expect( ActiveTriples::Solrizer::ProfileIndexingService.new(dr_indexed_vector).export ).to eq expected_object_profile_indexed_vector
70
+ end
71
+ end
72
+
73
+ context "when all properties indexed and guessing the type" do
74
+ it "should produce object profile holding serialization of the resource" do
75
+ expect( ActiveTriples::Solrizer::ProfileIndexingService.new(dr_indexed_guess).export ).to eq expected_object_profile_indexed_guess
76
+ end
77
+ end
78
+
79
+ context "when a property is a resource" do
80
+ before do
81
+ class DummyResourceB < ActiveTriples::Resource
82
+ configure :type => RDF::URI('http://example.org/SomeClass')
83
+ end
84
+ class DummyResourceA < ActiveTriples::Resource
85
+ configure :type => RDF::URI('http://example.org/SomeClass')
86
+ property :resource_b, :predicate => RDF::URI("http://example.org/ontology/related_object")
87
+ end
88
+ end
89
+
90
+ it "should put the object id in place of the resource" do
91
+ dr_b = DummyResourceB.new('http://www.example.org/dr_b')
92
+ dr_a = DummyResourceA.new('http://www.example.org/dr_a')
93
+ dr_a.resource_b = dr_b
94
+
95
+ expected_object_profile =
96
+ '{"id":"http://www.example.org/dr_a",'\
97
+ '"resource_b":"http://www.example.org/dr_b"}'
98
+
99
+ expect( ActiveTriples::Solrizer::ProfileIndexingService.new(dr_a).export ).to eq expected_object_profile
100
+ end
101
+ end
102
+ end
103
+
104
+ describe "#import" do
105
+ context "when all properties have values" do
106
+ it "should fill a resource with values by deserializing the object profile stored with the solr doc" do
107
+ filled_resource = ActiveTriples::Solrizer::ProfileIndexingService.new(dr_short_all_values).import( expected_object_profile_short_all_values )
108
+ expect( filled_resource.id ).to eq 'http://www.example.org/dr1'
109
+ expect( filled_resource.title ).to eq ['Test Title']
110
+ expect( filled_resource.description_si ).to eq ['Test text description stored and indexed.']
111
+ expect( filled_resource.borrower_uri_i ).to eq ['http://example.org/i/b2']
112
+ expect( filled_resource.clip_number_simr ).to eq [7,8,9,10]
113
+ expect( filled_resource.price_s ).to eq [789.01]
114
+ expect( filled_resource.bookEdition ).to eq ['Ed. 2']
115
+ end
116
+ end
117
+
118
+ context "when some properties do not have values" do
119
+ it "should fill a resource with values by deserializing the object profile stored with the solr doc" do
120
+ filled_resource = ActiveTriples::Solrizer::ProfileIndexingService.new(dr_short_partial_values).import( expected_object_profile_short_partial_values )
121
+ expect( filled_resource.id ).to eq 'http://www.example.org/dr1'
122
+ expect( filled_resource.title ).to eq ['Test Title']
123
+ expect( filled_resource.description_si ).to eq ['Test text description stored and indexed.']
124
+ expect( filled_resource.borrower_uri_i ).to eq []
125
+ expect( filled_resource.clip_number_simr ).to eq []
126
+ expect( filled_resource.price_s ).to eq [789.01]
127
+ expect( filled_resource.bookEdition ).to eq ['Ed. 2']
128
+ end
129
+ end
130
+
131
+ context "when properties have multiple values and all types represented" do
132
+ it "should fill a resource with values by deserializing the object profile stored with the solr doc" do
133
+ filled_resource = ActiveTriples::Solrizer::ProfileIndexingService.new(dr_stored_indexed_multi).import( expected_object_profile_stored_indexed_multi )
134
+ expect( filled_resource.id ).to eq 'http://www.example.org/dr_sim'
135
+ expect( filled_resource.title ).to eq ['Test Title','Title 2']
136
+ expect( filled_resource.description ).to eq ['Test text description stored and indexed and multi values.','Desc 2','Desc 3']
137
+ expect( filled_resource.borrower_uri ).to eq ['http://example.org/b_sim','http://example.org/b_sim3']
138
+ expect( filled_resource.clip_number ).to eq [3,4,5,6]
139
+ expect( filled_resource.answer_count ).to eq [12345678901234567893,32345678901234567893]
140
+ expect( filled_resource.price ).to eq [123.43,323.43]
141
+ expect( filled_resource.max_price ).to eq [12345678901234567.83,32345678901234567.83]
142
+ expect( filled_resource.modified_time ).to eq ['1995-12-31T23:59:53Z','2015-12-31T23:59:53Z']
143
+ expect( filled_resource.is_proprietary ).to eq [false,true]
144
+ # expect( filled_resource.latitude =
145
+ expect( filled_resource.bookEdition ).to eq ['Ed. 3','Ed. 3a']
146
+ end
147
+ end
148
+ end
149
+ end
@@ -0,0 +1,78 @@
1
+ require 'spec_helper'
2
+ require 'support/dummy_resource.rb'
3
+
4
+ describe ActiveTriples::Solrizer::PropertiesIndexingService do
5
+ include_context "shared dummy resource class"
6
+
7
+ describe "#export" do
8
+ context "when small number of properties" do
9
+ it "should produce object profile holding serialization of the resource" do
10
+ expect( ActiveTriples::Solrizer::PropertiesIndexingService.new(dr_short_all_values).export ).to eq expected_solr_properties_short_all_values
11
+ end
12
+
13
+ it "should produce object profile holding serialization of the resource" do
14
+ expect( ActiveTriples::Solrizer::PropertiesIndexingService.new(dr_short_partial_values).export ).to eq expected_solr_properties_short_partial_values
15
+ end
16
+ end
17
+
18
+ context "when all properties indexed" do
19
+ it "should produce object profile holding serialization of the resource" do
20
+ expect( ActiveTriples::Solrizer::PropertiesIndexingService.new(dr_indexed).export ).to eq expected_solr_properties_indexed
21
+ end
22
+ end
23
+
24
+ context "when all properties stored" do
25
+ it "should produce object profile holding serialization of the resource" do
26
+ expect( ActiveTriples::Solrizer::PropertiesIndexingService.new(dr_stored).export ).to eq expected_solr_properties_stored
27
+ end
28
+ end
29
+
30
+ context "when all properties stored and indexed" do
31
+ it "should produce object profile holding serialization of the resource" do
32
+ expect( ActiveTriples::Solrizer::PropertiesIndexingService.new(dr_stored_indexed).export ).to eq expected_solr_properties_stored_indexed
33
+ end
34
+ end
35
+
36
+ context "when all properties indexed and multi-valued" do
37
+ it "should produce object profile holding serialization of the resource" do
38
+ expect( ActiveTriples::Solrizer::PropertiesIndexingService.new(dr_indexed_multi).export ).to eq expected_solr_properties_indexed_multi
39
+ end
40
+ end
41
+
42
+ context "when all properties stored and multi-valued" do
43
+ it "should produce object profile holding serialization of the resource" do
44
+ expect( ActiveTriples::Solrizer::PropertiesIndexingService.new(dr_stored_multi).export ).to eq expected_solr_properties_stored_multi
45
+ end
46
+ end
47
+
48
+ context "when all properties stored and indexed and multi-valued" do
49
+ it "should produce object profile holding serialization of the resource" do
50
+ expect( ActiveTriples::Solrizer::PropertiesIndexingService.new(dr_stored_indexed_multi).export ).to eq expected_solr_properties_stored_indexed_multi
51
+ end
52
+ end
53
+
54
+ context "when all properties indexed and range" do
55
+ it "should produce object profile holding serialization of the resource" do
56
+ expect( ActiveTriples::Solrizer::PropertiesIndexingService.new(dr_indexed_range).export ).to eq expected_solr_properties_indexed_range
57
+ end
58
+ end
59
+
60
+ context "when all properties indexed and sortable" do
61
+ it "should produce object profile holding serialization of the resource" do
62
+ expect( ActiveTriples::Solrizer::PropertiesIndexingService.new(dr_indexed_sort).export ).to eq expected_solr_properties_indexed_sort
63
+ end
64
+ end
65
+
66
+ context "when all properties indexed and vectored" do
67
+ it "should produce object profile holding serialization of the resource" do
68
+ expect( ActiveTriples::Solrizer::PropertiesIndexingService.new(dr_indexed_vector).export ).to eq expected_solr_properties_indexed_vector
69
+ end
70
+ end
71
+
72
+ context "when all properties indexed and guessing the type" do
73
+ it "should produce object profile holding serialization of the resource" do
74
+ expect( ActiveTriples::Solrizer::PropertiesIndexingService.new(dr_indexed_guess).export ).to eq expected_solr_properties_indexed_guess
75
+ end
76
+ end
77
+ end
78
+ end