Topic: Delete Orphaned Search Records from Zebra
Topic type:
A short guide to how to delete individual records "by hand" from your Zebra databases.
Note: The following article is written for Kete 1.2 or later. For previous version, see an older version of this topic.
You need two things to delete a record from Zebra. A copy of the record and it's unique id. If you get the record, you can get the id out of it.
If the record has been deleted from the Kete Ruby on Rails web application, but still remains in the search/browse results, you'll need to connect to your Zebra database directly to get the record's content and id.
Follow this topic to connect:
http://old.kete.net.nz/documentation/topics/show/163-accessing-zebra-directly-with-yaz-client
Work through it up through the "format xml" step. Assuming you know the title of the orphaned record, we are going to run a query and get our it:
Z> f @attr 1=4 "User Manual" # this searches the title attribute for the exact phrase match of "User Manual" as the title
Sent searchRequest.
Received SearchResponse.
Search was a success.
Number of hits: 2, setno 1
SearchResult-1: term=User cnt=2, term=Manual cnt=1
records returned: 0
Elapsed: 0.010284
We have two matches (in this case, my orphaned record was a duplicate). Look at each record and determine which one is the orphan and save its xml to a file.
show 1
Sent presentRequest (1+1).
Records: 1
[public]Record type: XML
...
<identifier>oai:horowhenua.kete.net.nz:help:Topic:1346</identifier>
...
The first one is legit (it exists in both the search/browse results and I don't get a 404 when clicking on the result's link), so I need to see the content for the second match:
show 2
Z> show 2
Sent presentRequest (2+1).
Records: 1
[public]Record type: XML
...
<identifier>oai:horowhenua.kete.net.nz:adopt_an_anzac:Topic:2043</identifier>
...
Here we need to do grab the identifier of the record. Copy the value of the identifier element somewhere.
You can now close your connection to Zebra as per the rest of the linked topic, we'll use the Kete Rails app IRB console to delete the record from here.
From the command line run this to open your application's console:
$ script/console production # drop the "production" if you are connecting to your app's development mode
Loading production environment (Rails 2.1.0)
>> zoom_db = ZoomDb.first # assuming you want to connect to your public zoom database, use ZoomDb.find(2) if you want private database
>> zoom_id = "oai:horowhenua.kete.net.nz:adopt_an_anzac:Topic:2043" # use the identifier you noted earlier instead of what i have here
>> zoom_db.destroy_identified_by(zoom_id)
That should have deleted the record, confirm in your search/browse results. If it is gone, you are all done.
Repeat process for multiple deletes.