1313import java .util .Map ;
1414import lombok .RequiredArgsConstructor ;
1515import org .apache .commons .lang3 .tuple .Pair ;
16+ import org .apache .logging .log4j .LogManager ;
17+ import org .apache .logging .log4j .Logger ;
1618import org .opensearch .OpenSearchParseException ;
1719import org .opensearch .common .Numbers ;
1820import org .opensearch .common .geo .GeoPoint ;
2527/** The Implementation of Content to represent {@link JsonNode}. */
2628@ RequiredArgsConstructor
2729public class OpenSearchJsonContent implements Content {
28-
30+ private static final Logger LOG = LogManager . getLogger ();
2931 private final JsonNode value ;
3032
3133 @ Override
@@ -156,7 +158,10 @@ public Pair<Double, Double> geoValue() {
156158 GeoUtils .parseGeoPoint (parser , point , true );
157159 return Pair .of (point .getLat (), point .getLon ());
158160 } catch (IOException ex ) {
159- throw new OpenSearchParseException (String .format ("error parsing geo point %s" , value ), ex );
161+ if (LOG .isDebugEnabled ()) {
162+ LOG .debug ("Error parsing geo point '{}'" , value );
163+ }
164+ throw new OpenSearchParseException ("error parsing geo point" , ex );
160165 }
161166 }
162167
@@ -175,7 +180,11 @@ private long parseLongValue(JsonNode node) {
175180 }
176181 return Numbers .toLong (node .textValue (), true );
177182 } else {
178- throw new OpenSearchParseException (String .format ("node %s must be a number" , node ));
183+ if (LOG .isDebugEnabled ()) {
184+ LOG .debug ("node '{}' must be a number" , node );
185+ }
186+ throw new OpenSearchParseException (
187+ String .format ("node must be a number, found %s" , node .getNodeType ()));
179188 }
180189 }
181190
@@ -189,7 +198,11 @@ private double parseDoubleValue(JsonNode node) {
189198 }
190199 return Double .parseDouble (node .textValue ());
191200 } else {
192- throw new OpenSearchParseException (String .format ("node %s must be a number" , node ));
201+ if (LOG .isDebugEnabled ()) {
202+ LOG .debug ("node '{}' must be a number" , node );
203+ }
204+ throw new OpenSearchParseException (
205+ String .format ("node must be a number, found %s" , node .getNodeType ()));
193206 }
194207 }
195208
@@ -200,7 +213,11 @@ private boolean parseBooleanValue(JsonNode node) {
200213 } else if (node .isTextual ()) {
201214 return Boolean .parseBoolean (node .textValue ());
202215 } else {
203- throw new OpenSearchParseException (String .format ("node %s must be a boolean" , node ));
216+ if (LOG .isDebugEnabled ()) {
217+ LOG .debug ("node '{}' must be a boolean" , node );
218+ }
219+ throw new OpenSearchParseException (
220+ String .format ("node must be a boolean, found %s" , node .getNodeType ()));
204221 }
205222 }
206223}
0 commit comments