From d675f7b4851fe0c43efbceb1e6b231af0a34eb41 Mon Sep 17 00:00:00 2001 From: sashakames Date: Thu, 14 Nov 2019 13:40:36 -0800 Subject: [PATCH 1/5] add timestamp update --- .../main/esg/search/publish/impl/solr/SolrRetractor.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/java/main/esg/search/publish/impl/solr/SolrRetractor.java b/src/java/main/esg/search/publish/impl/solr/SolrRetractor.java index 09c1b285..95b3f202 100644 --- a/src/java/main/esg/search/publish/impl/solr/SolrRetractor.java +++ b/src/java/main/esg/search/publish/impl/solr/SolrRetractor.java @@ -25,6 +25,10 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Date; + +import java.time.format.DateTimeFormatter; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -78,8 +82,11 @@ public void consume(final Record record) throws Exception { // also set "latest=false" String query = "id="+record.getId(); Map metadata = new HashMap(); + Date thedate = new Date(System.currentTimeMillis()); + DateTimeFormatter dtf = new DateTimeFormatter(); metadata.put(QueryParameters.FIELD_RETRACTED, new String[] {"true"} ); metadata.put(QueryParameters.FIELD_LATEST, new String[] {"false"} ); + metadata.put(QueryParameters.FIELD_TIMESTAMP, dtf.ISO_INSTANT.format(thedate) ); HashMap> doc = new HashMap>(); doc.put(query, metadata); updateService.update(solrUrl.toString(), From bec05a008efb92eeaf5584978a7160e3f5288c86 Mon Sep 17 00:00:00 2001 From: sashakames Date: Fri, 15 Nov 2019 07:41:45 -0800 Subject: [PATCH 2/5] fix use of DateTimeFormatter --- src/java/main/esg/search/publish/impl/solr/SolrRetractor.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/java/main/esg/search/publish/impl/solr/SolrRetractor.java b/src/java/main/esg/search/publish/impl/solr/SolrRetractor.java index 95b3f202..c75a75fe 100644 --- a/src/java/main/esg/search/publish/impl/solr/SolrRetractor.java +++ b/src/java/main/esg/search/publish/impl/solr/SolrRetractor.java @@ -83,10 +83,10 @@ public void consume(final Record record) throws Exception { String query = "id="+record.getId(); Map metadata = new HashMap(); Date thedate = new Date(System.currentTimeMillis()); - DateTimeFormatter dtf = new DateTimeFormatter(); + metadata.put(QueryParameters.FIELD_RETRACTED, new String[] {"true"} ); metadata.put(QueryParameters.FIELD_LATEST, new String[] {"false"} ); - metadata.put(QueryParameters.FIELD_TIMESTAMP, dtf.ISO_INSTANT.format(thedate) ); + metadata.put(QueryParameters.FIELD_TIMESTAMP, DateTimeFormatter.ISO_INSTANT.format(thedate) ); HashMap> doc = new HashMap>(); doc.put(query, metadata); updateService.update(solrUrl.toString(), From 89c05ca33fcda5e9392a353f4c2f2a94b93de7b1 Mon Sep 17 00:00:00 2001 From: sashakames Date: Fri, 15 Nov 2019 07:58:38 -0800 Subject: [PATCH 3/5] change to instant --- src/java/main/esg/search/publish/impl/solr/SolrRetractor.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/java/main/esg/search/publish/impl/solr/SolrRetractor.java b/src/java/main/esg/search/publish/impl/solr/SolrRetractor.java index c75a75fe..274c8232 100644 --- a/src/java/main/esg/search/publish/impl/solr/SolrRetractor.java +++ b/src/java/main/esg/search/publish/impl/solr/SolrRetractor.java @@ -25,7 +25,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Date; +import java.time.Instant; import java.time.format.DateTimeFormatter; @@ -82,7 +82,7 @@ public void consume(final Record record) throws Exception { // also set "latest=false" String query = "id="+record.getId(); Map metadata = new HashMap(); - Date thedate = new Date(System.currentTimeMillis()); + Instant thedate = Instant.now(); metadata.put(QueryParameters.FIELD_RETRACTED, new String[] {"true"} ); metadata.put(QueryParameters.FIELD_LATEST, new String[] {"false"} ); From 16a983c4229582c09b63aa99279332e1cb57bd16 Mon Sep 17 00:00:00 2001 From: sashakames Date: Fri, 15 Nov 2019 09:21:54 -0800 Subject: [PATCH 4/5] make a String [] --- src/java/main/esg/search/publish/impl/solr/SolrRetractor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/java/main/esg/search/publish/impl/solr/SolrRetractor.java b/src/java/main/esg/search/publish/impl/solr/SolrRetractor.java index 274c8232..fbcde1da 100644 --- a/src/java/main/esg/search/publish/impl/solr/SolrRetractor.java +++ b/src/java/main/esg/search/publish/impl/solr/SolrRetractor.java @@ -86,7 +86,7 @@ public void consume(final Record record) throws Exception { metadata.put(QueryParameters.FIELD_RETRACTED, new String[] {"true"} ); metadata.put(QueryParameters.FIELD_LATEST, new String[] {"false"} ); - metadata.put(QueryParameters.FIELD_TIMESTAMP, DateTimeFormatter.ISO_INSTANT.format(thedate) ); + metadata.put(QueryParameters.FIELD_TIMESTAMP, new String[] {DateTimeFormatter.ISO_INSTANT.format(thedate)} ); HashMap> doc = new HashMap>(); doc.put(query, metadata); updateService.update(solrUrl.toString(), From a2280ceb5722de913b74aebbb1ecf2fb33c6ecb8 Mon Sep 17 00:00:00 2001 From: sashakames Date: Mon, 18 Nov 2019 16:06:13 -0800 Subject: [PATCH 5/5] correct the timestamp (working otherwise) --- src/java/main/esg/search/publish/impl/solr/SolrRetractor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/java/main/esg/search/publish/impl/solr/SolrRetractor.java b/src/java/main/esg/search/publish/impl/solr/SolrRetractor.java index fbcde1da..330fc409 100644 --- a/src/java/main/esg/search/publish/impl/solr/SolrRetractor.java +++ b/src/java/main/esg/search/publish/impl/solr/SolrRetractor.java @@ -86,7 +86,7 @@ public void consume(final Record record) throws Exception { metadata.put(QueryParameters.FIELD_RETRACTED, new String[] {"true"} ); metadata.put(QueryParameters.FIELD_LATEST, new String[] {"false"} ); - metadata.put(QueryParameters.FIELD_TIMESTAMP, new String[] {DateTimeFormatter.ISO_INSTANT.format(thedate)} ); + metadata.put(QueryParameters.FIELD_TIMESTAMP_, new String[] {DateTimeFormatter.ISO_INSTANT.format(thedate)} ); HashMap> doc = new HashMap>(); doc.put(query, metadata); updateService.update(solrUrl.toString(),