-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsimplest_possible_traject_config.rb
More file actions
52 lines (30 loc) · 1.18 KB
/
simplest_possible_traject_config.rb
File metadata and controls
52 lines (30 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# This very simple traject file is (a) totally self-contained,
# and (b) just uses a debug writer to write things out.
# For a more complete example of indexing code, look at
# the index.rb file in this directory
# You can run this against a binary marc file 'myfile.mrc' as:
#
# traject -c ./simplest_possible_traject_config myfile.mrc
# Set up a reader and a writer
# First we need to require the reader/writer we want
require 'traject'
require 'traject/marc_reader'
require 'traject/debug_writer'
# The add the appropriate settings
settings do
provide "reader_class_name", "Traject::MarcReader"
provide "marc_source.type", "xml"
provide "writer_class_name", "Traject::DebugWriter"
provide "output_file", "debug_output.txt"
provide 'processing_thread_pool', 2
# Right now, logging is going to $stderr. Uncomment
# this line to send it to a file
# provide 'log.file', 'traject.log'
end
# Log what version of ruby or jruby we're using
logger.info RUBY_DESCRIPTION
# index the id, title, and author
to_field "id", extract_marc("001", :first => true)
to_field "title", extract_marc('245')
to_field "author", extract_marc('100abcd:110abcd:111abc')
# That's it!