[QUESTION] toJsonString() with Java 8 time module
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 25/100
Línea de trabajo
Comienza en SearchRequest.toJsonString() y en la configuración de JacksonJsonpMapper mostrada en el issue; después, sigue el rastro de qué mapper serializa los valores de JsonData. Reproduce el ejemplo de consulta de rango con OffsetDateTime y compara el mapper usado para la serialización de la request con el ObjectMapper configurado; se considera completado cuando se identifica una ruta de serialización compatible o se documenta la configuración necesaria.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Hi,
I don't seem to be able to serialise SearchRequest(for example) if i am using OffsetDateTime in my range query.
For example:
OffsetDateTime from, OffsetDateTime to;
BoolQuery.Builder bool = QueryBuilders.bool();
bool.filter(QueryBuilders.range().field("ts").from(JsonData.of(from)).to(JsonData.of(to)).build().toQuery());
SearchRequest searchRequest = new SearchRequest.Builder()
.size(10000)
.query(bool.build().toQuery())
.index(Arrays.stream(indices).toList()).build();
System.out.println(searchRequest.toJsonString());// This is where the error is
The error is
jakarta.json.JsonException: Cannot find a serializer for type java.time.OffsetDateTime. Consider using a full-featured JsonpMapper.
This is how i init my Opensearch client and setting the mapper which has the timeModule
private OpenSearchClient getClientInternal() {
final HttpHost host = new HttpHost("https",hostname);
final BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(new AuthScope(host), new UsernamePasswordCredentials(username, password.toCharArray()));
JsonpMapper mapper = new JacksonJsonpMapper(jacksonObjectMapper);
var transport = ApacheHttpClient5TransportBuilder.builder(host)
.setMapper(mapper) //**Set the mapper here which has the timeModule**
.setHttpClientConfigCallback(httpClientBuilder -> httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider)
)
.build();
return new OpenSearchClient(transport);
}
My ObjectMapper config
@Bean
public ObjectMapper jacksonObjectMapper() {
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
System.out.println("Auto-configured Jackson ObjectMapper bean created. "+ mapper.hashCode());
return mapper;
}
I don't see anything wrong, but i still get the error.
Any ideas ?
- Lenguaje dominante
- Java
- Estrellas
- 165
- Forks
- 257
- Merge medio
- 1 d 1 h
- PR fusionados (30 d)
- 44
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de opensearch-project/opensearch-java
-
[BUG] ArrayDeserializer.acceptedEvents() publishes a half-built set; concurrent first-use rejects single-value arraysPosiblemente ocupada @vinirib la tomó hace 1 día. Abiertobug v3.11.0
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
opensearch-project/opensearch-java#2252 · 4 comentarios ·
Los mantenedores suelen responder en 1 día
-
enhancement untriaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
opensearch-project/opensearch-java#2188 ·
Los mantenedores suelen responder en 1 día
-
[BUG] "shape" should not be required in GeoShapeQueryFieldQuizá libre de nuevo @lsh1215 la tomó hace 123 días y no hay ningún pull request abierto. Abiertobug untriaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
opensearch-project/opensearch-java#2011 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
untriaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
opensearch-project/opensearch-java#2008 ·
Los mantenedores suelen responder en 1 día
-
[BUG] ISM types lastUpdatedTime is susceptible to int overflowPosiblemente ocupada @gingeekrishna la tomó hace 119 días. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
opensearch-project/opensearch-java#1898 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de opensearch-project/opensearch-java
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
ballerina-platform/ballerina-library#9437 ·
Los mantenedores suelen responder en 1 día
-
Documentation
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
OWASP/SecurityShepherd#1097 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Dans-Plugins/Medieval-Roleplay-Engine#392 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Only some languages can be selectedPosiblemente ocupada @imnotjames la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
grimmory-tools/grimmory#3040 ·
Los mantenedores suelen responder en 1 día
-
Invalid If-Modified-Since or If-Unmodified-Since header results in 500 with Request.evaluatePreconditions()Posiblemente ocupada @pschaub la tomó hoy. Abiertokind/bug triage/needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día