From 3669ce96d22ae11ffcd2db0156facc513177418b Mon Sep 17 00:00:00 2001 From: Alan Orth Date: Thu, 10 Nov 2016 18:32:16 +0200 Subject: [PATCH] Update notes for 2016-11-10 --- content/post/2016-11.md | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/content/post/2016-11.md b/content/post/2016-11.md index e6b1d6929..e05f17ae7 100644 --- a/content/post/2016-11.md +++ b/content/post/2016-11.md @@ -177,7 +177,7 @@ dspacetest=# select distinct text_lang from metadatavalue where resource_type_id (14 rows) ``` -- Generate a list of all these so I can fix them in batch: +- Generate a list of all these so I can maybe fix them in batch: ``` dspace=# \copy (select distinct text_lang, count(*) from metadatavalue where resource_type_id=2 group by text_lang order by count desc) to /tmp/text-langs.csv with csv; @@ -190,3 +190,30 @@ COPY 14 dspace=# update metadatavalue set text_lang='en_US' where resource_type_id=2 and metadata_field_id=203 and text_value='SEEDS'; UPDATE 85 ``` + +- The `fix-metadata.py` script I have is meant for specific metadata values, so if I want to update some `text_lang` values I should just do it directly in the database +- For example, on a limited set: + +``` +dspace=# update metadatavalue set text_lang=NULL where resource_type_id=2 and metadata_field_id=203 and text_value='LIVESTOCK' and text_lang=''; +UPDATE 420 +``` + +- And assuming I want to do it for all fields: + +``` +dspacetest=# update metadatavalue set text_lang=NULL where resource_type_id=2 and text_lang=''; +UPDATE 183726 +``` + +- After that restarted Tomcat and PostgreSQL (because I'm superstitious about caches) and now I see the following in REST API query: + +``` +$ curl -s -H "accept: application/json" -H "Content-Type: application/json" -X POST "http://localhost:8080/rest/items/find-by-metadata-field" -d '{"key": "cg.subject.ilri","value": "SEEDS"}' | jq length +71 +$ curl -s -H "accept: application/json" -H "Content-Type: application/json" -X POST "http://localhost:8080/rest/items/find-by-metadata-field" -d '{"key": "cg.subject.ilri","value": "SEEDS", "language":""}' | jq length +0 +$ curl -s -H "accept: application/json" -H "Content-Type: application/json" -X POST "http://localhost:8080/rest/items/find-by-metadata-field" -d '{"key": "cg.subject.ilri","value": "SEEDS", "language":"en_US"}' | jq length +``` + +- Not sure what's going on, but Discovery shows 83 values, and database shows 85, so I'm going to reindex Discovery just in case