hydra 6.2.0.rc1 → 6.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -1
  3. data/CONTRIBUTING.md +3 -0
  4. data/RELEASE-POLICY.md +40 -0
  5. data/doc/Configuring-solr-and-fedora.md +16 -0
  6. data/doc/Content-Type-Example:-Journal-Article.textile +735 -0
  7. data/doc/Dive-into-Hydra.md +62 -0
  8. data/doc/Filtering-search-results-with-hydra-access-controls.md +16 -0
  9. data/doc/For-Developers.md +47 -0
  10. data/doc/Home.md +33 -0
  11. data/doc/Lesson:-Define-Relationships-Between-Objects.md +127 -0
  12. data/doc/Lesson:-Generate-Rails-Scaffolding-for-Creating-and-Editing-Books.md +167 -0
  13. data/doc/Lesson:-Reading-Hydra-rightsMetadata-XML.md +87 -0
  14. data/doc/Lesson:-Use-Hydra-Access-Controls-to-Control-Access-to-Blacklight-show-Pages.md +37 -0
  15. data/doc/Lesson:-Using-Hydra-Access-Controls-and-CanCan-to-conditionally-render-part-of-a-page.md +29 -0
  16. data/doc/Lesson:-add-the-Hydra-dependencies.md +28 -0
  17. data/doc/Lesson:-adding-content-datastreams.md +60 -0
  18. data/doc/Lesson:-build-a-book-model.md +262 -0
  19. data/doc/Lesson:-create-a-git-repository.md +35 -0
  20. data/doc/Lesson:-generate-a-rails-application.md +53 -0
  21. data/doc/Lesson:-install-hydra-jetty.md +57 -0
  22. data/doc/Lesson:-make-blacklight-return-search-results.md +47 -0
  23. data/doc/Lesson:-run-the-Hydra-generator.md +39 -0
  24. data/doc/Lesson:-set-up-your-Rails-Application-to-use-rspec.md +41 -0
  25. data/doc/Lesson:-start-jetty.md +85 -0
  26. data/doc/Lesson:-start-the-application-&-search-for-results.md +43 -0
  27. data/doc/Lesson:-turn-off-access-controls.md +37 -0
  28. data/doc/Migrating-to-Hydra-6.2.md +12 -0
  29. data/doc/Migration-Notes.md +2 -0
  30. data/doc/Models---Defining-a-Custom-Hydra-Model.textile +198 -0
  31. data/doc/Rake-Tasks-in-Hydra-Head.textile +40 -0
  32. data/doc/Reference.textile +19 -0
  33. data/doc/Solr-Schema.rdoc +44 -0
  34. data/doc/Tools-for-Developing-and-Testing-your-Application.textile +69 -0
  35. data/doc/YOUR-Hydra-Application---Initial-Modifications.textile +357 -0
  36. data/lib/hydra/version.rb +1 -1
  37. metadata +35 -4
@@ -0,0 +1,87 @@
1
+ This Tutorial is known to work with hydra-head version 6.0.0..
2
+ _Please update this wiki to reflect any other versions that have been tested._
3
+
4
+ # Steps
5
+
6
+ Given a book whose permissions look like this:
7
+ ```text
8
+ puts book.permissions
9
+ {:type=>"group", :access=>"discover", :name=>"group2"}
10
+ {:type=>"group", :access=>"read", :name=>"group3"}
11
+ {:type=>"group", :access=>"read", :name=>"group9"}
12
+ {:type=>"group", :access=>"read", :name=>"group8"}
13
+ {:type=>"user", :access=>"read", :name=>"user3"}
14
+ {:type=>"user", :access=>"edit", :name=>"bob1"}
15
+ {:type=>"user", :access=>"edit", :name=>"sally2"}
16
+ ```
17
+
18
+ The permissions will be written into the rightsMetadata datstream like so
19
+ ```xml
20
+ puts book.rightsMetadata.to_xml
21
+ <rightsMetadata xmlns="http://hydra-collab.stanford.edu/schemas/rightsMetadata/v1" version="0.1">
22
+ <copyright>
23
+ <human type="title"/>
24
+ <human type="description"/>
25
+ <machine type="uri"/>
26
+ </copyright>
27
+ <access type="discover">
28
+ <human/>
29
+ <machine>
30
+ <group>group2</group>
31
+ </machine>
32
+ </access>
33
+ <access type="read">
34
+ <human/>
35
+ <machine>
36
+ <group>group3</group>
37
+ <group>group9</group>
38
+ <group>group8</group>
39
+ <person>user3</person>
40
+ </machine>
41
+ </access>
42
+ <access type="edit">
43
+ <human/>
44
+ <machine>
45
+ <person>bob1</person>
46
+ <person>sally2</person>
47
+ </machine>
48
+ </access>
49
+ <embargo>
50
+ <human/>
51
+ <machine/>
52
+ </embargo>
53
+ </rightsMetadata>
54
+ ```
55
+
56
+ If we remove the nodes that aren't relevant to this lesson, the XML looks like this:
57
+
58
+ ```xml
59
+ <rightsMetadata xmlns="http://hydra-collab.stanford.edu/schemas/rightsMetadata/v1" version="0.1">
60
+ <access type="discover">
61
+ <machine>
62
+ <group>group2</group>
63
+ </machine>
64
+ </access>
65
+ <access type="read">
66
+ <machine>
67
+ <group>group3</group>
68
+ <group>group9</group>
69
+ <group>group8</group>
70
+ <person>user3</person>
71
+ </machine>
72
+ </access>
73
+ <access type="edit">
74
+ <machine>
75
+ <person>bob1</person>
76
+ <person>sally2</person>
77
+ </machine>
78
+ </access>
79
+ </rightsMetadata>
80
+ ```
81
+
82
+ As you can see, group ids are put into `<group>` nodes and user ids are put into `<person>` nodes. The type of access being granted is decided by the @type attribute on the `<access>` nodes.
83
+
84
+ The intermediary `<machine>` node is meant to allow you to insert human-readable information into the 'access/human' node while inserting the machine-readable assertions into 'access/machine' node.
85
+
86
+ # Next Step
87
+ Go on to [[Lesson: Indexing Hydra Rights Metadata into Solr]] or return to the [[Access Controls with Hydra]] tutorial.
@@ -0,0 +1,37 @@
1
+ This Tutorial is known to work with hydra-head version 6.0.0.
2
+ _Please update this wiki to reflect any other versions that have been tested._
3
+
4
+ # Goals
5
+
6
+ # Explanation
7
+
8
+ # Steps
9
+
10
+ ### Step 1: Enforce Show permissions on Blacklight search results
11
+
12
+ When we turned off access controls as part of the [[Dive into Hydra]] tutorial, we commented out two lines. The first line was turning on gated discovery. We covered that in the previous lesson. The other line was telling Blacklight to prevent unauthorized access to `show` views for items from your searches. Let's enable that filter and see what it does.
13
+
14
+ Open app/controllers/catalog_controller.rb and find these lines
15
+ ```ruby
16
+ # These before_filters apply the hydra access controls
17
+ # before_filter :enforce_show_permissions, :only=>:show
18
+ ```
19
+
20
+ Uncomment the line with the `before_filter`
21
+ ```ruby
22
+ # These before_filters apply the hydra access controls
23
+ before_filter :enforce_show_permissions, :only=>:show
24
+ ```
25
+
26
+ ### Step 2: Test the enforcement of Show permissions on Blacklight search results
27
+
28
+ In your browser, log into the application as yourself, run a search, and click on the link to a book that you only have `discover` access to. Depending on what experiments you've done based on the previous lesson, you might have to go into the `rails console` and either create a new book that you have discover access to or modify an existing book to give you discover access.
29
+
30
+ You should have been redirected back to the search results page with a message reading _"You do not have sufficient access privileges to read this document, which has been marked private."_
31
+
32
+ **Note:** For this example, it's important that you to _only_ have discover access (not `read` or `edit`) and that none of the groups you belong to have `read` or `edit` access either. If you or one of your groups has `read` or `edit` access then you will see the book's `show` page instead of being redirected by the access controls.
33
+
34
+ In the `rails console`, grant yourself 'read' or 'edit' access to the book and save the book. Then in the browser you will be able to visit the `show` page for that book instead of being redirected like before.
35
+
36
+ # Next Step
37
+ Go on to [[Lesson: Use Hydra Access Controls and CanCan to decide whether to render a page]] or return to the [[Access Controls with Hydra]] tutorial.
@@ -0,0 +1,29 @@
1
+ This Tutorial is known to work with hydra-head version 6.0.0.
2
+ _Please update this wiki to reflect any other versions that have been tested._
3
+
4
+ # Goals
5
+
6
+ # Explanation
7
+
8
+ # Steps
9
+
10
+ ### Step: Use `can?` to conditionally render html on a page
11
+
12
+ In `app/views/books/show.html.erb` find the code that's displaying the "Edit" and "Back" links at the bottom of the page.
13
+ ```erb
14
+ <%= link_to 'Edit', edit_book_path(@book) %> |
15
+ <%= link_to 'Back', books_path %>
16
+ ```
17
+
18
+ Use an `if ... end` clause to only show the "Edit" link if the current user has permission to edit the current book.
19
+ ```erb
20
+ <%- if can?(:edit, @book) %>
21
+ <%= link_to 'Edit', edit_book_path(@book) %> |
22
+ <%- end %>
23
+ <%= link_to 'Back', books_path %>
24
+ ```
25
+
26
+ Now go into the `rails console` and give yourself `edit` access to one book but only `read` access for another. Look at the show views for the two books. You should see the "Edit" link on the book that you have permission to edit and you should not see the "Edit" link for the book that you do not have permission to edit.
27
+
28
+ # Next Step
29
+ Return to the [[Access Controls with Hydra]] tutorial.
@@ -0,0 +1,28 @@
1
+ This lesson is known to work with hydra (gem) version 6.1.0.
2
+ _Please update this wiki to reflect any other versions that have been tested._
3
+
4
+ # Goals
5
+ * Add the Hydra software to your application's list of dependencies
6
+ * Use bundler to install dependencies
7
+
8
+ # Explanation
9
+
10
+ In order to take advantage of the Hydra code and features in your application, you need to tell the application where to find that code and which versions of that code to use. Rails uses a tool called [bundler](http://bundler.io/) to track dependencies. Bundler looks in the file called `Gemfile` to know what you want installed.
11
+
12
+ # Steps
13
+
14
+ Open up ```Gemfile``` in your editor. We're going to add the following lines:
15
+
16
+ ```ruby
17
+ gem 'hydra', require: 'hydra6'
18
+ ```
19
+
20
+ This declares our application to have a dependency on the hydra6 release version of the hydra-gem and ensures that the hydra-head gem gets included (required) correctly. This includes a dependency for the jettywrapper gem (installed automatically). The jettywrapper gem is used to install and configure a preconfigured instance of jetty that loads and runs local development instances of Fedora and Solr for you to run and test your application against.
21
+
22
+ Now we save the file and install the dependencies by running bundler:
23
+ ```text
24
+ $ bundle install
25
+ ```
26
+
27
+ # Next Step
28
+ Go on to [[Lesson: Run the Hydra generator]] or return to the [[Dive into Hydra]] page.
@@ -0,0 +1,60 @@
1
+ This lesson is known to work with hydra version 6.1.0.
2
+ _Please update this wiki to reflect any other versions that have been tested._
3
+
4
+ # Goals
5
+ * Add "file-bearing" Datastreams to models and objects
6
+ * See where files are stored in Fedora objects and how to retrieve them
7
+
8
+ # Explanation
9
+
10
+ So far, we've only added datastreams that bear metadata. Let's add a datastream that has some content to it. For example, this could be a content datastream in our book model that is an image of the book's cover, or a datastream added to the page model that is an image or pdf of that actual page.
11
+
12
+ In this case, we'll add a file datastream where we can store a pdf of a page.
13
+
14
+ # Steps
15
+
16
+ ### Step 1: Add a "pageContent" file datastream to the Page model
17
+
18
+ In our Page model ```app/models/page.rb```, we'll add the following line underneath our descMetadata datastream:
19
+
20
+ ```ruby
21
+ has_file_datastream "pageContent"
22
+ ```
23
+
24
+ Now we have a datastream called "pageContent" that can hold any kind of file we wish to add to it.
25
+
26
+ ### Step 2: In the console, add a file to a Page object and save it
27
+
28
+ To add the file to one of our page objects, open up the console again:
29
+
30
+ ```ruby
31
+ > p = Page.find("changeme:2")
32
+ => #<Page pid:"changeme:2", number:[1], text:["Happy families are all alike; every unhappy family is unhappy in its own way."]>
33
+ > p.datastreams.keys
34
+ => ["DC", "RELS-EXT", "descMetadata", "pageContent"]
35
+ ```
36
+
37
+ Now you're ready to add the file. Choose a file on your computer that you want to add as the "pageContent". In the lines below we're pretending that the path to the file is "/Users/adamw/Desktop/page1.pdf". Replace that with the correct local path for the file you want to use.
38
+
39
+ ```ruby
40
+ > p.pageContent.content = File.open("/Users/adamw/Desktop/page1.pdf")
41
+ => #<File:/Users/adamw/Desktop/page1.pdf>
42
+ > p.save
43
+ => true
44
+ ```
45
+
46
+ ### Step 3: See where the file Datastream was saved in Fedora
47
+
48
+ Now if you go to [[http://localhost:8983/fedora/objects/changeme:2/datastreams]], you'll see the pageContent datastream in Fedora. Following the links to it will allow us to view or download the file we've added.
49
+
50
+ ### Step 4: Commit your changes
51
+
52
+ Now that we've added a content datastream, it's a great time to commit to git:
53
+
54
+ ```bash
55
+ $> git add .
56
+ $> git commit -m "Created a content datastream"
57
+ ```
58
+
59
+ # Next Step
60
+ Proceed to [[Lesson: Generate Rails Scaffolding for Creating and Editing Books]] or explore other [Dive into Hydra](Dive into Hydra#bonus) tutorial bonus lessons.
@@ -0,0 +1,262 @@
1
+ This lesson is known to work with hydra release version 6.1.0.
2
+ _Please update this wiki to reflect any other versions that have been tested._
3
+
4
+ # Goals
5
+ * Define a simple OM (Opinionated Metadata) Terminology for Book Metadata that we will track as XML Datastreams
6
+ * Start the Rails console and run code interactively in the console
7
+ * Create Datastream objects that use your OM Terminology
8
+ * Define an ActiveFedora Model for Book objects
9
+ * Declare a Datastream called descMetadata on your Book model and make it use your Book Metadata Terminology
10
+ * Delegate methods from Book objects to their descMetadata Datastream
11
+ * Create Book objects that use your Book Model
12
+ * See how an object has been indexed into Solr
13
+ * See how & where objects and metadata are stored in Fedora
14
+ * Use OM to Manage how your Metadata is indexed in Solr
15
+ * Re-index objects into Solr (update Solr based on any changes to an object, its Model, or the OM Terminologies it uses)
16
+
17
+ # Explanation
18
+ In Fedora an object can have many 'datastreams' which are either content for the object or metadata about the object. We are going to create a 'book' object. This object will have a metadata datastream which will contain some XML that describes the properties of the book. We'll call this datastream 'descMetadata'. You are free to call it whatever you like, but 'descMetadata' is a loose convention that stands for 'descriptive metadata'.
19
+
20
+ Once you've created an object and saved it in Fedora, you also want to be able to search for it in Solr. ActiveFedora and OM make it easy to get your metadata into Solr and manage if/when/how your metadata is indexed.
21
+
22
+ # Steps
23
+
24
+ ### Step 1: Create an OM Terminology for Book Metadata
25
+
26
+ First we'll create a Ruby class that represents this descriptive metadata. Make a new directory for our datastreams by typing in
27
+ ```bash
28
+ $> mkdir app/models/datastreams
29
+ ```
30
+
31
+ Now we'll create a file called `app/models/datastreams/book_metadata.rb`
32
+
33
+ Paste the following code into that file:
34
+
35
+ ```ruby
36
+ class BookMetadata < ActiveFedora::OmDatastream
37
+
38
+ set_terminology do |t|
39
+ t.root(path: "fields")
40
+ t.title
41
+ t.author
42
+ end
43
+
44
+ def self.xml_template
45
+ Nokogiri::XML.parse("<fields/>")
46
+ end
47
+ end
48
+ ```
49
+
50
+ This class extends from OmDatastream. OM is a gem that allows us to describe the format of an xml file and access properties. We are using OM by calling the `set_terminology` method. The xml_template method tells OM how to create a new xml document for this class.
51
+
52
+ **Tip:** If you want to learn about OM Terminologies and how they work, visit the [Tame your XML with OM](https://github.com/projecthydra/om/wiki/Tame-your-XML-with-OM) Tutorial.
53
+
54
+ ### Step 2: Start the Rails console
55
+
56
+ Let's take a look at how this class works. We'll start the rails console by typing
57
+
58
+ ```bash
59
+ $> rails console
60
+ ```
61
+
62
+ You should see something like `Loading development environment (Rails 3.2.11)`. Now you're in a "[REPL](http://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop)", or *interactive ruby console* that has all of your Rails application's code and configuration loaded.
63
+
64
+ ### Step 3: In the console, create Datastream objects that use your OM Terminology
65
+
66
+ Let's create a new BookMetadata instance. I've shown the expected output after each command:
67
+
68
+ ```text
69
+ d = BookMetadata.new
70
+ => #<BookMetadata @pid="" @dsid="" @controlGroup="X" changed="false" @mimeType="text/xml" >
71
+ d.title = "ZOIA! Memoirs of Zoia Horn, Battler for the People's Right to Know."
72
+ => "ZOIA! Memoirs of Zoia Horn, Battler for the People's Right to Know."
73
+ d.author = "Horn, Zoia"
74
+ => "Horn, Zoia"
75
+ d.to_xml
76
+ => "<fields>\n <title>ZOIA! Memoirs of Zoia Horn, Battler for the People's Right to Know.</title>\n <author>Horn, Zoia</author>\n</fields>"
77
+ ```
78
+
79
+ Once you're done, exit the console by typing ```exit```
80
+
81
+
82
+ ### Step 4: Define a Book Model
83
+
84
+ Now let's, create a model that uses this datastream. Create a new file at `app/models/book.rb`. We'll paste in this code:
85
+
86
+ ```ruby
87
+ class Book < ActiveFedora::Base
88
+ has_metadata 'descMetadata', type: BookMetadata
89
+
90
+ has_attributes :title, datastream: 'descMetadata', multiple: false
91
+ has_attributes :author, datastream: 'descMetadata', multiple: false
92
+
93
+ end
94
+ ```
95
+
96
+ We've defined our Book model to use the BookMetadata for its datastream called 'descMetadata'. We're telling the model to use the descMetadata as the delegate for the properties 'title' and 'author'. We are also telling Active Fedora to treat these attributes as single values rather than as multi-valued arrays.
97
+
98
+ ### Step 5: In the console, create Datastream objects that use your OM Terminology
99
+
100
+ Now we'll open the `rails console` again and see how to work with our book.
101
+
102
+ ```text
103
+ b = Book.create(title: 'Anna Karenina', author: 'Tolstoy, Leo')
104
+ => #<Book pid:"changeme:1", title:["Anna Karenina"], author:["Tolstoy, Leo"]>
105
+ ```
106
+
107
+ We've created a new Book object in the repository. You can see that it has a pid (Fedora Commons persistence identifier) of 'changeme:1'. Because you set title and author to delegate to the descMetadata datastream, they are stored in that datastream's XML and can be accessed either through the delegated methods on the Book, or by going specifically to the datastream.
108
+
109
+
110
+ ```text
111
+ b.descMetadata
112
+ => #<BookMetadata @pid="changeme:1" @dsid="descMetadata" @controlGroup="M" changed="false" @mimeType="text/xml" >
113
+ b.title
114
+ => "Anna Karenina"
115
+ b.author
116
+ => "Tolstoy, Leo"
117
+ b.descMetadata.title
118
+ => ["Anna Karenina"]
119
+ b.descMetadata.author
120
+ => ["Tolstoy, Leo"]
121
+ ```
122
+
123
+
124
+ ### Step 6: See what your Book objects look like in Fedora and Solr
125
+
126
+ If we go to [[http://localhost:8983/fedora/objects/changeme:1]] we should see what it looks like in fedora. Note especially that the xml datastream has been ingested [[http://localhost:8983/fedora/objects/changeme:1/datastreams/descMetadata/content]]. The content of that datastream should look like this in your browser:
127
+
128
+ ```xml
129
+ <fields>
130
+ <title>Anna Karenina</title>
131
+ <author>Tolstoy, Leo</author>
132
+ </fields>
133
+ ```
134
+
135
+ Let's also see that this book has been ingested into the Solr search index. [[http://localhost:8983/solr/select?q=changeme:1]]. It should look like the sample below. Note that, at this point, the title and author have not been stored in solr. You only get fields like `system_create_dtsi`, `system_modified_dtsi`, `id`, `object_profile_ssm`, and `has_model_ssim`. In the next step we will modify our BookMetadata datastream to add the book metadata to the solr document.
136
+
137
+ ```xml
138
+ <?xml version="1.0"?>
139
+ <response>
140
+ <lst name="responseHeader">
141
+ <int name="status">0</int>
142
+ <int name="QTime">3</int>
143
+ <lst name="params">
144
+ <str name="q">changeme:4</str>
145
+ </lst>
146
+ </lst>
147
+ <result name="response" numFound="1" start="0" maxScore="0.05991731">
148
+ <doc>
149
+ <date name="system_create_dtsi">2013-05-06T16:22:39Z</date>
150
+ <date name="system_modified_dtsi">2013-05-06T16:22:39Z</date>
151
+ <arr name="active_fedora_model_ssim">
152
+ <str>Book</str>
153
+ </arr>
154
+ <str name="id">changeme:4</str>
155
+ <arr name="object_profile_ssm">
156
+ <str>{"datastreams":{"RELS-EXT":{"dsLabel":"Fedora Object-to-Object Relationship Metadata","dsVersionID":"RELS-EXT.0","dsCreateDate":"2013-05-06T16:22:40Z","dsState":"A","dsMIME":"application/rdf+xml","dsFormatURI":null,"dsControlGroup":"X","dsSize":277,"dsVersionable":true,"dsInfoType":null,"dsLocation":"changeme:4+RELS-EXT+RELS-EXT.0","dsLocationType":null,"dsChecksumType":"DISABLED","dsChecksum":"none"},"descMetadata":{"dsLabel":null,"dsVersionID":"descMetadata.0","dsCreateDate":"2013-05-06T16:22:41Z","dsState":"A","dsMIME":"text/xml","dsFormatURI":null,"dsControlGroup":"M","dsSize":81,"dsVersionable":true,"dsInfoType":null,"dsLocation":"changeme:4+descMetadata+descMetadata.0","dsLocationType":"INTERNAL_ID","dsChecksumType":"DISABLED","dsChecksum":"none"},"rightsMetadata":{}},"objLabel":null,"objOwnerId":"fedoraAdmin","objModels":["info:fedora/fedora-system:FedoraObject-3.0"],"objCreateDate":"2013-05-06T16:22:39Z","objLastModDate":"2013-05-06T16:22:39Z","objDissIndexViewURL":"http://localhost:8983/fedora/objects/changeme%3A4/methods/fedora-system%3A3/viewMethodIndex","objItemIndexViewURL":"http://localhost:8983/fedora/objects/changeme%3A4/methods/fedora-system%3A3/viewItemIndex","objState":"A"}</str>
157
+ </arr>
158
+ <arr name="has_model_ssim">
159
+ <str>info:fedora/afmodel:Book</str>
160
+ </arr>
161
+ <date name="timestamp">2013-05-06T16:22:58.397Z</date>
162
+ <float name="score">0.05991731</float>
163
+ </doc>
164
+ </result>
165
+ <lst name="facet_counts">
166
+ <lst name="facet_queries"/>
167
+ <lst name="facet_fields">
168
+ <lst name="active_fedora_model_ssi"/>
169
+ <lst name="object_type_si"/>
170
+ </lst>
171
+ <lst name="facet_dates"/>
172
+ <lst name="facet_ranges"/>
173
+ </lst>
174
+ </response>
175
+ ```
176
+ ### Step 7: See how your Book metadata are indexed into Solr
177
+
178
+
179
+ The to_solr method is what generates the solr document for your objects and their datastreams. To see the full solr document for the book we created, call
180
+
181
+ ```text
182
+ b.to_solr
183
+ ```
184
+
185
+ To see just the part of the solr document that comes from the descMetadata datastream (which has our book title and author), call
186
+
187
+ ```text
188
+ b.descMetadata.to_solr
189
+ => {}
190
+ ```
191
+
192
+ As you can see, the descMetadata datastream is returning an empty Hash, meaning that it isn't indexing the author and title values.
193
+
194
+ ### Step 8: Change how your Book metadata are indexed into Solr
195
+
196
+ To make the BookMetadata Terminology index the author and title fields, you need to reopen `app/models/datastreams/book_metadata.rb` and change the terminology section to look like this:
197
+
198
+ ```ruby
199
+ set_terminology do |t|
200
+ t.root(path: "fields")
201
+ t.title(index_as: :stored_searchable)
202
+ t.author(index_as: :stored_searchable)
203
+ end
204
+ ```
205
+
206
+ **Note:** Because we have made changes to our Ruby code that we want to use, we need to restart the Rails console so that it will reload all of the code, including our latest changes.
207
+
208
+ Now, **restart the rails console** and we can load the object we previously created:
209
+
210
+ ```text
211
+ b = Book.find('changeme:1')
212
+ => #<Book pid:"changeme:1", title:"Anna Karenina", author:"Tolstoy, Leo">
213
+ ```
214
+
215
+ Check and see that to_solr includes the title and author fields.
216
+
217
+ ```text
218
+ b.descMetadata.to_solr
219
+ => {"title_tesim"=>["Anna Karenina"], "author_tesim"=>["Tolstoy, Leo"]}
220
+ ```
221
+ Now when you call `.to_solr` on a BookMetadata datastream it returns a solr document with fields named `title_tesim` and `author_tesim` that contain your title and author values. Those are the field names that we will add to Blacklight's queries in [[Lesson: Make Blacklight Return Search Results]].
222
+
223
+
224
+ ### Step 9: Re-index an object in Solr
225
+
226
+ Now we'll call the ```update_index``` method, which republishes the Solr document using the changes we've made.
227
+
228
+ ```text
229
+ b.update_index
230
+ => {"responseHeader"=>{"status"=>0, "QTime"=>25}}
231
+ ```
232
+
233
+ If you refresh the document result from solr ([[http://localhost:8983/solr/select?q=changeme:1]]) you should see that these fields have been added to the solr_document:
234
+
235
+ ```xml
236
+ <arr name="title_tesim">
237
+ <str>Anna Karenina</str>
238
+ </arr>
239
+ <arr name="author_tesim">
240
+ <str>Tolstoy, Leo</str>
241
+ </arr>
242
+ ```
243
+
244
+ **Aside:** The strange suffixes on the field names are provided by [solrizer](http://github.com/projecthydra/solrizer). You can read about them in the solrizer documentaton. In short, the **_tesim** suffix tells Solr to treat the values as _**t**ext_ in the _**e**nglish_ language that should be _**s**tored_, _**i**ndexed_ and allowed to be _**m**ultivalued_. This _tesim suffix is a useful catch-all that gets your searches working predictably with minimal fuss. As you encounter cases where you need to index your content in more nuanced ways, there are ways to change these suffixes in order to achieve different results in Solr.
245
+
246
+ #### Why doesn't the Book show up in Blacklight?
247
+
248
+ Now your object is indexed properly, but it **won't show up in Blacklight's search results** until you've turned off access controls and added the appropriate fields to Blacklight's queries. We cover those in the next 2 lessons.
249
+
250
+ ### Step 10: Commit your changes
251
+
252
+ Now that we've got our model working, it's a great time to commit to git:
253
+
254
+ ```bash
255
+ $> git add .
256
+ $> git commit -m "Created a book model and a datastream"
257
+ ```
258
+
259
+ # Next Step
260
+ Go on to [[Lesson: Turn Off Access Controls]] or return to the [[Dive into Hydra]] page.
261
+
262
+ If you want to learn about OM Terminologies and how they work, visit the [Tame your XML with OM](https://github.com/projecthydra/om/wiki/Tame-your-XML-with-OM) Tutorial.