base_indexer 3.0.0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +40 -0
- data/.travis.yml +17 -0
- data/Gemfile +49 -0
- data/LICENSE +13 -0
- data/README.md +151 -0
- data/app/controllers/base_indexer/about_controller.rb +1 -1
- data/base_indexer.gemspec +40 -0
- data/code_diagram.png +0 -0
- data/config/initializers/base_indexer.rb +0 -2
- data/config/initializers/config.rb +6 -0
- data/lib/base_indexer.rb +0 -3
- data/lib/base_indexer/engine.rb +0 -9
- data/lib/base_indexer/main_indexer_engine.rb +5 -6
- data/lib/base_indexer/solr/client.rb +3 -3
- data/lib/base_indexer/version.rb +1 -1
- data/lib/generators/base_indexer/install_generator.rb +1 -1
- data/lib/generators/base_indexer/templates/settings.yml +5 -0
- data/lib/tasks/index.rake +4 -4
- data/spec/base_indexer/main_indexer_engine_spec.rb +46 -0
- data/spec/base_indexer/solr/client_spec.rb +47 -0
- data/spec/base_indexer/solr/writer_spec.rb +72 -0
- data/spec/controllers/base_indexer/items_controller_spec.rb +36 -0
- data/spec/fixtures/vcr_cassettes/available_mods_xml.yml +105 -0
- data/spec/fixtures/vcr_cassettes/available_purl_xml.yml +110 -0
- data/spec/fixtures/vcr_cassettes/get_collection_name_for_item.yml +197 -0
- data/spec/fixtures/vcr_cassettes/read_mods_in_vaild.yml +154 -0
- data/spec/fixtures/vcr_cassettes/read_mods_vaild.yml +199 -0
- data/spec/fixtures/vcr_cassettes/read_purl_in_vaild.yml +154 -0
- data/spec/fixtures/vcr_cassettes/read_purl_vaild.yml +197 -0
- data/spec/fixtures/vcr_cassettes/rsolr_client_delete.yml +174 -0
- data/spec/fixtures/vcr_cassettes/rsolr_client_index.yml +115 -0
- data/spec/fixtures/vcr_cassettes/rsolr_update.yml +313 -0
- data/spec/spec_helper.rb +112 -0
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +14 -0
- metadata +72 -14
- data/lib/base_indexer/config/solr_configuration.rb +0 -17
- data/lib/base_indexer/config/solr_configuration_from_file.rb +0 -25
- data/lib/generators/base_indexer/templates/solr.yml +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9044a8dc8006eb311f4a709b071fd22bdc635115
|
4
|
+
data.tar.gz: d89c940569d6c4003e3fc6f2a9a68b4971e98c66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 364f6a44ea77b4470279180a0b35f0124ab68dca3c5a77389dc6a6283d9ed5b81b0c6455e1f4bdc03abef2a7f9f9380209dcc99119c0a6e30a97e365f906e32f
|
7
|
+
data.tar.gz: 65b5a40a35a4cd47f65d990e30cd94554ae4ab9cd2ad77539e9bced88f56653f4e04b639c4722cdbafa7787deae45cffe02edab10c0d49a99f19f988ab716f6e
|
data/.gitignore
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
Gemfile.lock
|
12
|
+
|
13
|
+
## Specific to RubyMotion:
|
14
|
+
.dat*
|
15
|
+
.repl_history
|
16
|
+
build/
|
17
|
+
|
18
|
+
## Documentation cache and generated files:
|
19
|
+
/.yardoc/
|
20
|
+
/_yardoc/
|
21
|
+
/doc/
|
22
|
+
/rdoc/
|
23
|
+
|
24
|
+
## Environment normalisation:
|
25
|
+
/.bundle/
|
26
|
+
/vendor/bundle
|
27
|
+
/lib/bundler/man/
|
28
|
+
|
29
|
+
# for a library or gem, you might want to ignore these files since the code is
|
30
|
+
# intended to run in multiple environments; otherwise, check them in:
|
31
|
+
# Gemfile.lock
|
32
|
+
# .ruby-version
|
33
|
+
# .ruby-gemset
|
34
|
+
|
35
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
36
|
+
.rvmrc
|
37
|
+
|
38
|
+
.internal_test_app
|
39
|
+
/spec/internal
|
40
|
+
./spec/internal
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Declare your gem's dependencies in base_indexer.gemspec.
|
4
|
+
# Bundler will treat runtime dependencies like base dependencies, and
|
5
|
+
# development dependencies will be added by default to the :development group.
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
# Declare any dependencies that are still in development here instead of in
|
9
|
+
# your gemspec. These might include edge Rails or gems from your path or
|
10
|
+
# Git. Remember to move these dependencies to your gemspec before releasing
|
11
|
+
# your gem to rubygems.org.
|
12
|
+
|
13
|
+
# To use debugger
|
14
|
+
# gem 'debugger'
|
15
|
+
|
16
|
+
# BEGIN ENGINE_CART BLOCK
|
17
|
+
# engine_cart: 0.10.0
|
18
|
+
# engine_cart stanza: 0.10.0
|
19
|
+
# the below comes from engine_cart, a gem used to test this Rails engine gem in the context of a Rails app.
|
20
|
+
file = File.expand_path('Gemfile', ENV['ENGINE_CART_DESTINATION'] || ENV['RAILS_ROOT'] || File.expand_path('.internal_test_app', File.dirname(__FILE__)))
|
21
|
+
if File.exist?(file)
|
22
|
+
begin
|
23
|
+
eval_gemfile file
|
24
|
+
rescue Bundler::GemfileError => e
|
25
|
+
Bundler.ui.warn '[EngineCart] Skipping Rails application dependencies:'
|
26
|
+
Bundler.ui.warn e.message
|
27
|
+
end
|
28
|
+
else
|
29
|
+
Bundler.ui.warn "[EngineCart] Unable to find test application dependencies in #{file}, using placeholder dependencies"
|
30
|
+
|
31
|
+
if ENV['RAILS_VERSION']
|
32
|
+
if ENV['RAILS_VERSION'] == 'edge'
|
33
|
+
gem 'rails', github: 'rails/rails'
|
34
|
+
ENV['ENGINE_CART_RAILS_OPTIONS'] = '--edge --skip-turbolinks'
|
35
|
+
else
|
36
|
+
gem 'rails', ENV['RAILS_VERSION']
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
case ENV['RAILS_VERSION']
|
41
|
+
when /^4.2/
|
42
|
+
gem 'responders', '~> 2.0'
|
43
|
+
gem 'sass-rails', '>= 5.0'
|
44
|
+
gem 'coffee-rails', '~> 4.1.0'
|
45
|
+
when /^4.[01]/
|
46
|
+
gem 'sass-rails', '< 5.0'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
# END ENGINE_CART BLOCK
|
data/LICENSE
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright 2014 The Board of Trustees of the Leland Stanford Junior University.
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/sul-dlss/base_indexer.svg?branch=master)](https://travis-ci.org/sul-dlss/base_indexer) [![Coverage Status](https://coveralls.io/repos/github/sul-dlss/base_indexer/badge.svg?branch=master)](https://coveralls.io/github/sul-dlss/base_indexer) [![Gem Version](https://badge.fury.io/rb/base_indexer.png)](http://badge.fury.io/rb/base_indexer)
|
2
|
+
|
3
|
+
# BaseIndexer
|
4
|
+
|
5
|
+
## Running tests
|
6
|
+
|
7
|
+
First time setup and to generate all docs:
|
8
|
+
|
9
|
+
$ rake
|
10
|
+
|
11
|
+
Just run the tests next time around:
|
12
|
+
|
13
|
+
$ bundle exec rake spec
|
14
|
+
|
15
|
+
|
16
|
+
## Steps to hook the base_indexer engine in your app
|
17
|
+
### Generate new rails app
|
18
|
+
$ rails new my_indexer_app
|
19
|
+
|
20
|
+
### Edit Gemfile and add the base_indexer gem name
|
21
|
+
gem 'base_indexer'
|
22
|
+
|
23
|
+
### Run bundle install to download the gem
|
24
|
+
$ bundle install
|
25
|
+
|
26
|
+
## Run the install generator
|
27
|
+
```sh
|
28
|
+
$ rails g base_indexer:install
|
29
|
+
```
|
30
|
+
|
31
|
+
## Basic configuration
|
32
|
+
The engine is looking for the following values
|
33
|
+
|
34
|
+
config.solr_config_file_path = "#{config.root}/config/solr.yml"
|
35
|
+
DiscoveryIndexer::PURL_DEFAULT='https://purl.stanford.edu'
|
36
|
+
|
37
|
+
## Advanced features
|
38
|
+
|
39
|
+
The engine gives the developer the ability to extend any of its classes
|
40
|
+
|
41
|
+
To extend any of indexer features (purl-reader, mods-reader, mapper, solr-writer)
|
42
|
+
|
43
|
+
1. Create a new class that inherits from BaseIndexer::MainIndexerEngine
|
44
|
+
2. Create a new file named config/initializers/base_indexer.rb
|
45
|
+
3. In this file, add the following line. replace 'MyIndexerClassName' with the fully qualifed actual class name. The name should be between double qoutes
|
46
|
+
BaseIndexer.indexer_class = "MyIndexerClassName"
|
47
|
+
4. In the new indexer class, you can override any of the functions that you need to change its implementation. For example, if you need to use a new mapper, you will override map function.
|
48
|
+
|
49
|
+
To extend mapper functionality.
|
50
|
+
1. Create a new class e.g., MyMapper that inherits from GeneralMapper or IndexMapper.
|
51
|
+
2. Implement MyMapper.map to converts the input to solr doc hash.
|
52
|
+
3. Override MyIndexerClassName.map to call your new class instead of the default one.
|
53
|
+
|
54
|
+
## Rake Tasks For Indexing Druids
|
55
|
+
|
56
|
+
All rake tasks that perform batch indexing will generate log files in the "log" folder within the app itself. You can tail the log file to watch the progress. The log file is also useful since you can pass it to the "reindexer" rake task to retry just the errored out druids. The name of the log file will depend on which rake task you are running, and will be timestamped to be unique.
|
57
|
+
|
58
|
+
### Index a single druid:
|
59
|
+
|
60
|
+
$ rake index RAILS_ENV=production target=revs_prod druid=oo000oo0001
|
61
|
+
|
62
|
+
### Index a list of druids from a pre-assembly run, a remeditaion run, or a simple CSV:
|
63
|
+
|
64
|
+
$ rake log_indexer RAILS_ENV=production target=revs_prod log_file=/tmp/mailander_1.yaml log_type=preassembly = preassembly run
|
65
|
+
|
66
|
+
$ nohup rake log_indexer RAILS_ENV=production target=revs_prod log_file=/tmp/mailander_1.yaml log_type=preassembly & = for a long running process, which will be most runs that have more than a few dozen druids, nohup it
|
67
|
+
|
68
|
+
$ rake log_indexer RAILS_ENV=production target=revs_prod log_file=/tmp/mailander_1_remediate.yaml log_type=remediate = remediation run
|
69
|
+
|
70
|
+
$ rake log_indexer RAILS_ENV=production target=revs_prod log_file=/tmp/mailander.csv log_type=csv = a simple csv file -- it must have a header line, with the header of "druid" definining the items you wish to index
|
71
|
+
|
72
|
+
### Index an entire collection, including the collection itself, along with all of its members (be sure to check the fetcher_url parameter in the Rails environment you are running under to be sure it is connecting where you expect):
|
73
|
+
|
74
|
+
$ rake collection_indexer RAILS_ENV=production target=revs_prod collection_druid=oo000oo0001
|
75
|
+
$ nohup rake collection_indexer RAILS_ENV=production target=revs_prod collection_druid=oo000oo0001 & = for a long running process, e.g. a collection with more than a few dozen druids, nohup it
|
76
|
+
|
77
|
+
### Re-Index Just Errored Out Items
|
78
|
+
|
79
|
+
If you had errors when indexing from a preassembly/remediation log or from indexing an entire collection, you can re-run the errored out druids only with the log file. All log files are kept in the log folder in the revs-indexer-service app.
|
80
|
+
|
81
|
+
$ rake reindexer RAILS_ENV=production target=revs_prod file=log/logfile.log
|
82
|
+
|
83
|
+
$ nohup rake reindexer RAILS_ENV=production target=revs_prod file=log/logfile.log & = probably no need to nohup unless there were alot of errors
|
84
|
+
|
85
|
+
### Delete Druids
|
86
|
+
|
87
|
+
Delete a list of druids specified in a CSV/txt file. Be careful, this will delete from all targets! Put one druid per line, no header is necessary.
|
88
|
+
|
89
|
+
$ rake delete_druids RAILS_ENV=production file=druid_list.txt
|
90
|
+
|
91
|
+
### Delete a single druid
|
92
|
+
|
93
|
+
$ rake delete RAILS_ENV=production druid=oo000oo0001
|
94
|
+
|
95
|
+
# HTTP API
|
96
|
+
|
97
|
+
### Items
|
98
|
+
|
99
|
+
#### `/items/:druid`
|
100
|
+
|
101
|
+
`DELETE /items/:druid`
|
102
|
+
|
103
|
+
##### Summary
|
104
|
+
Deletes a druid from all registered subtargets.
|
105
|
+
|
106
|
+
##### Parameters
|
107
|
+
Name | Located In | Description | Required | Schema | Default
|
108
|
+
---- | ---------- | ----------- | -------- | ------ | -------
|
109
|
+
`druid` | url | object identifier | yes | String |
|
110
|
+
|
111
|
+
##### Responses
|
112
|
+
Code | Description
|
113
|
+
---- | -----------
|
114
|
+
`200` | Request received and successfully processed for all subtargets
|
115
|
+
`500` | Request received but did not complete successfully (one or more subtargets may have not been deleted)
|
116
|
+
|
117
|
+
#### `/items/:druid/subtargets/:subtarget`
|
118
|
+
|
119
|
+
`DELETE /items/:druid/subtargets/:subtarget`
|
120
|
+
|
121
|
+
##### Summary
|
122
|
+
Deletes a druid from a specific subtarget.
|
123
|
+
|
124
|
+
##### Parameters
|
125
|
+
Name | Located In | Description | Required | Schema | Default
|
126
|
+
---- | ---------- | ----------- | -------- | ------ | -------
|
127
|
+
`druid` | url | object identifier | yes | String |
|
128
|
+
`subtarget` | url | subtarget name (usually capitialized) | yes | String |
|
129
|
+
|
130
|
+
##### Responses
|
131
|
+
Code | Description
|
132
|
+
---- | -----------
|
133
|
+
`200` | Request received and successfully processed for subtarget
|
134
|
+
`500` | Request received but did not complete successfully
|
135
|
+
|
136
|
+
`PATCH/PUT /items/:druid/subtargets/:subtarget`
|
137
|
+
|
138
|
+
##### Summary
|
139
|
+
Indexes a druid from a specific subtarget.
|
140
|
+
|
141
|
+
##### Parameters
|
142
|
+
Name | Located In | Description | Required | Schema | Default
|
143
|
+
---- | ---------- | ----------- | -------- | ------ | -------
|
144
|
+
`druid` | url | object identifier | yes | String |
|
145
|
+
`subtarget` | url | subtarget name (usually capitialized) | yes | String |
|
146
|
+
|
147
|
+
##### Responses
|
148
|
+
Code | Description
|
149
|
+
---- | -----------
|
150
|
+
`200` | Request received and successfully processed for subtarget
|
151
|
+
`500` | Request received but did not complete successfully
|
@@ -6,7 +6,7 @@ module BaseIndexer
|
|
6
6
|
|
7
7
|
def version
|
8
8
|
@result = { app_name: Rails.configuration.app_name, rails_env: Rails.env, version: Rails.configuration.app_version, last_restart: (File.exist?('tmp/restart.txt') ? File.new('tmp/restart.txt').mtime : 'n/a'), last_deploy: (File.exist?('REVISION') ? File.new('REVISION').mtime : 'n/a'), revision: (File.exist?('REVISION') ? File.read('REVISION') : 'n/a') }
|
9
|
-
@result.update(solr_cores:
|
9
|
+
@result.update(solr_cores: Settings.SOLR_TARGETS)
|
10
10
|
@result.update(gems: Gem.loaded_specs) if request.format.html?
|
11
11
|
|
12
12
|
respond_to do |format|
|
@@ -0,0 +1,40 @@
|
|
1
|
+
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
|
2
|
+
|
3
|
+
# Maintain your gem's version:
|
4
|
+
require 'base_indexer/version'
|
5
|
+
|
6
|
+
# Describe your gem and declare its dependencies:
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = 'base_indexer'
|
9
|
+
s.version = BaseIndexer::VERSION
|
10
|
+
s.authors = ['Ahmed Alsum','Laney McGlohon']
|
11
|
+
s.email = ['laneymcg@stanford.edu']
|
12
|
+
s.summary = 'Summary of BaseIndexer.'
|
13
|
+
s.description = 'Description of BaseIndexer.'
|
14
|
+
s.license = 'Apache 2'
|
15
|
+
|
16
|
+
s.files = `git ls-files -z`.split("\x0")
|
17
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
18
|
+
s.bindir = 'exe'
|
19
|
+
s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
s.add_dependency 'rails', '>= 4', '< 6'
|
23
|
+
s.add_dependency 'discovery-indexer', '>= 2', '< 4'
|
24
|
+
s.add_dependency 'retries'
|
25
|
+
s.add_dependency 'dor-fetcher'
|
26
|
+
s.add_dependency 'config'
|
27
|
+
|
28
|
+
s.add_development_dependency 'sqlite3'
|
29
|
+
|
30
|
+
s.add_development_dependency 'rspec'
|
31
|
+
s.add_development_dependency 'rspec-rails'
|
32
|
+
s.add_development_dependency 'capybara'
|
33
|
+
s.add_development_dependency 'vcr'
|
34
|
+
s.add_development_dependency 'webmock'
|
35
|
+
s.add_development_dependency 'coveralls'
|
36
|
+
s.add_development_dependency 'yard' # for documentation
|
37
|
+
|
38
|
+
s.add_development_dependency 'engine_cart'
|
39
|
+
s.add_development_dependency 'jettywrapper'
|
40
|
+
end
|
data/code_diagram.png
ADDED
Binary file
|
@@ -2,7 +2,5 @@
|
|
2
2
|
# Define the indexer class that will be used by the engine.
|
3
3
|
# The engine consumer app should override this class
|
4
4
|
BaseIndexer.indexer_class = 'BaseIndexer::MainIndexerEngine'
|
5
|
-
BaseIndexer.solr_configuration_class_name = 'BaseIndexer::SolrConfigurationFromFile'
|
6
|
-
# BaseIndexer.solr_configuration_class.constantize.new(Rails.configuration.solr_config_file_path)
|
7
5
|
BaseIndexer.mapper_class_name = 'DiscoveryIndexer::GeneralMapper'
|
8
6
|
BaseIndexer.solr_writer_class_name = 'BaseIndexer::Solr::Writer'
|
data/lib/base_indexer.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
require 'base_indexer/engine'
|
2
2
|
|
3
3
|
require 'base_indexer/main_indexer_engine'
|
4
|
-
require 'base_indexer/config/solr_configuration'
|
5
|
-
require 'base_indexer/config/solr_configuration_from_file'
|
6
4
|
require 'base_indexer/solr/client'
|
7
5
|
require 'base_indexer/solr/writer'
|
8
6
|
require 'discovery-indexer'
|
@@ -10,6 +8,5 @@ module BaseIndexer
|
|
10
8
|
mattr_accessor :indexer_class
|
11
9
|
mattr_accessor :mapper_class_name
|
12
10
|
mattr_accessor :solr_writer_class_name
|
13
|
-
mattr_accessor :solr_configuration_class_name
|
14
11
|
mattr_accessor :fetcher_class
|
15
12
|
end
|
data/lib/base_indexer/engine.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'active_support/core_ext/numeric/bytes'
|
2
|
-
|
3
1
|
module BaseIndexer
|
4
2
|
class Engine < ::Rails::Engine
|
5
3
|
isolate_namespace BaseIndexer
|
@@ -14,13 +12,6 @@ module BaseIndexer
|
|
14
12
|
config.app_name = '[You have to override this name in your app]'
|
15
13
|
|
16
14
|
config.after_initialize do
|
17
|
-
config.solr_config_file = File.join(Rails.root, 'config', 'solr.yml')
|
18
|
-
|
19
|
-
if File.exist? config.solr_config_file
|
20
|
-
# Reads the SOLR configuration file
|
21
|
-
BaseIndexer.solr_configuration_class_name.constantize.instance.read(config.solr_config_file)
|
22
|
-
end
|
23
|
-
|
24
15
|
# Initializes the DiscoveryIndexer log with Rails logger, so all the messages will go to
|
25
16
|
# the same log file
|
26
17
|
DiscoveryIndexer::Logging.logger = Rails.logger
|
@@ -21,8 +21,7 @@ module BaseIndexer
|
|
21
21
|
# It is the main indexing function
|
22
22
|
#
|
23
23
|
# @param druid [String] is the druid for an object e.g., ab123cd4567
|
24
|
-
# @param targets [Array] is an array with the targets list to index towards
|
25
|
-
# if it is nil, the method will read the target list from release_tags
|
24
|
+
# @param targets [Array] is an array with the targets list to index towards
|
26
25
|
#
|
27
26
|
# @raise it will raise erros if there is any problems happen in any level
|
28
27
|
def index(druid, targets = nil)
|
@@ -30,15 +29,15 @@ module BaseIndexer
|
|
30
29
|
solr_doc = BaseIndexer.mapper_class_name.constantize.new(druid).convert_to_solr_doc
|
31
30
|
|
32
31
|
# Get SOLR configuration and write
|
33
|
-
|
34
|
-
|
32
|
+
BaseIndexer.solr_writer_class_name.constantize.new
|
33
|
+
.process(druid, solr_doc, targets, Settings.SOLR_TARGETS.to_hash.deep_stringify_keys)
|
35
34
|
end
|
36
35
|
|
37
36
|
# It deletes an item defined by druid from all registered solr core
|
38
37
|
# @param druid [String] is the druid for an object e.g., ab123cd4567
|
39
38
|
def delete(druid)
|
40
|
-
|
41
|
-
|
39
|
+
BaseIndexer.solr_writer_class_name.constantize.new
|
40
|
+
.solr_delete_from_all(druid, Settings.SOLR_TARGETS.to_hash.deep_stringify_keys)
|
42
41
|
end
|
43
42
|
|
44
43
|
end
|
@@ -42,14 +42,14 @@ module BaseIndexer
|
|
42
42
|
DiscoveryIndexer::Logging.logger.debug "Attempt #{attempt} for #{id}"
|
43
43
|
|
44
44
|
if is_delete
|
45
|
-
DiscoveryIndexer::Logging.logger.info "Deleting #{id} on attempt #{attempt}"
|
46
45
|
solr_connector.delete_by_id(id, :add_attributes => {:commitWithin => 10000})
|
46
|
+
DiscoveryIndexer::Logging.logger.info "Deleting #{id} on attempt #{attempt}"
|
47
47
|
elsif allow_update?(solr_connector) && doc_exists?(id, solr_connector)
|
48
|
-
DiscoveryIndexer::Logging.logger.info "Updating #{id} on attempt #{attempt}"
|
49
48
|
update_solr_doc(id, solr_doc, solr_connector)
|
49
|
+
DiscoveryIndexer::Logging.logger.info "Updating #{id} on attempt #{attempt}"
|
50
50
|
else
|
51
|
-
DiscoveryIndexer::Logging.logger.info "Indexing #{id} on attempt #{attempt}"
|
52
51
|
solr_connector.add(solr_doc, :add_attributes => {:commitWithin => 10000})
|
52
|
+
DiscoveryIndexer::Logging.logger.info "Indexing #{id} on attempt #{attempt}"
|
53
53
|
end
|
54
54
|
#solr_connector.commit
|
55
55
|
DiscoveryIndexer::Logging.logger.info "Completing #{id} successfully on attempt #{attempt}"
|