diff --git a/src/main/java/org/ecocean/Encounter.java b/src/main/java/org/ecocean/Encounter.java index 4fc0858f01..da7d7d2d0f 100644 --- a/src/main/java/org/ecocean/Encounter.java +++ b/src/main/java/org/ecocean/Encounter.java @@ -4119,7 +4119,8 @@ public void opensearchDocumentSerializer(JsonGenerator jgen) Double dlat = this.getDecimalLatitudeAsDouble(); Double dlon = this.getDecimalLongitudeAsDouble(); - if ((dlat == null) || (dlon == null)) { + if ((dlat == null) || !Util.isValidDecimalLatitude(dlat) || (dlon == null) || + !Util.isValidDecimalLongitude(dlon)) { jgen.writeNullField("locationGeoPoint"); } else { jgen.writeObjectFieldStart("locationGeoPoint"); @@ -4300,7 +4301,13 @@ public static int[] opensearchSyncIndex(Shepherd myShepherd, int stopAfter) int ct = 0; for (String id : needIndexing) { Encounter enc = myShepherd.getEncounter(id); - if (enc != null) os.index(indexName, enc); + try { + if (enc != null) os.index(indexName, enc); + } catch (Exception ex) { + System.out.println("Encounter.opensearchSyncIndex(): index failed " + enc + " => " + + ex.toString()); + ex.printStackTrace(); + } if (ct % 500 == 0) System.out.println("Encounter.opensearchSyncIndex needIndexing: " + ct + "/" + rtn[0]); diff --git a/src/main/webapp/appadmin/opensearchSync.jsp b/src/main/webapp/appadmin/opensearchSync.jsp index b913c7a9a8..ccde192a20 100644 --- a/src/main/webapp/appadmin/opensearchSync.jsp +++ b/src/main/webapp/appadmin/opensearchSync.jsp @@ -8,6 +8,8 @@ org.ecocean.* <% System.out.println("opensearchSync.jsp begun..."); +long timer = System.currentTimeMillis(); +Util.mark("opensearchSync begin"); boolean resetIndex = Util.requestParameterSet(request.getParameter("resetIndex")); @@ -23,6 +25,14 @@ if ("".equals(fstr)) { if (forceNum == 0) forceNum = 999999; +String sstr = request.getParameter("startNum"); +int startNum = -1; +if (sstr != null) { + try { + startNum = Integer.parseInt(sstr); + } catch (Exception ex) {} +} + Shepherd myShepherd = new Shepherd(request); OpenSearch os = new OpenSearch(); @@ -45,10 +55,19 @@ if (forceNum > 0) { while (itr.hasNext()) { Encounter enc = (Encounter)itr.next(); if (!Util.stringExists(enc.getId())) continue; + ct++; + if (startNum > 0) { + if (ct < startNum) continue; + if (ct == startNum) System.out.println("opensearchSync.jsp: starting at " + startNum); + } //System.out.println(enc.getId() + ": " + enc.getVersion()); - enc.opensearchIndex(); + try { + enc.opensearchIndex(); + } catch (Exception ex) { + System.out.println("opensearchSync.jsp: exception failure on " + enc); + ex.printStackTrace(); + } if (ct % 100 == 0) System.out.println("opensearchSync.jsp: count " + ct); - ct++; if (ct > forceNum) break; } @@ -62,5 +81,6 @@ myShepherd.rollbackAndClose(); os.deleteAllPits(); System.out.println("opensearchSync.jsp finished"); +Util.mark("opensearchSync ended", timer); %>