Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
03-25-2021 05:29 PM
Hi all,
I´m using java and SDN6
I have and endpoint that return a list of "Feed"
the query cypher return this:
and I have to map this field "v" into Feed.java
Feed.java
when I map the v as listaProp y get this error:
ERROR 46684 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.util.MissingFormatArgumentException: Format specifier '%s'] with root cause
java.util.MissingFormatArgumentException: Format specifier '%s'
at java.base/java.util.Formatter.format(Formatter.java:2672) ~[na:na]
at java.base/java.util.Formatter.format(Formatter.java:2609) ~[na:na]
at java.base/java.lang.String.format(String.java:2897) ~[na:na]
at org.springframework.data.neo4j.repository.query.DtoInstantiatingConverter.lambda$getPropertyValueFor$2(DtoInstantiatingConverter.java:134) ~[spring-data-neo4j-6.0.5.jar:6.0.5]
at org.springframework.core.log.LogMessage$SupplierMessage.buildString(LogMessage.java:155) ~[spring-core-5.3.4.jar:5.3.4]
at org.springframework.core.log.LogMessage.toString(LogMessage.java:70) ~[spring-core-5.3.4.jar:5.3.4]
at java.base/java.lang.String.valueOf(String.java:2951) ~[na:na]
Thanks in advance!
Regards
03-26-2021 08:57 AM
You cannot just tell SDN to map arbitrary information into a map.
So there are a few things in here that need more information.
Feed
? It seems not to be a defined entity.The problem itself seems to be a smaller bug on our side to not populate the warning message correctly but in the end, it will produce what it says: null
for the field.
03-29-2021 06:55 AM
Hi Gerry. Thanks for your response.
Feed.java is not a node, is a class made for result only and I need to use custom queries
I need a non-domain result so I'm going to do it this way:
Spring Data Neo4j.
I only need no return the field "v" from a cypher query to an endpoint that return a json.
It´s the only way to do it, right?
Do you have any link where I have a small complete example of this?
Thanks a lot
03-29-2021 11:27 AM
at the end I use:
(sevice.java)
public Collection<ResultFeed> findListaPropFeed(String email) {
return this.neo4jClient
.query("match p=(u:User {eMail:$email})-[:INTERESADO_EN]->(:Concept)<-[:RELACIONADO_CON]-(e)\r\n"
+ "call apoc.case([labels(e)[0]='Lex', 'RETURN labels(e)[0] as label, e.id as id, e.titulo as titulo, e.fechaDisposicion_txt as fecha, \"BOE/EURLEX\" as fuente'\r\n"
+ " ,labels(e)[0]='New', 'RETURN labels(e)[0] as label, e.id as id, e.titulo as titulo, e.fecha_txt as fecha, \"EFSA\" as fuente' \r\n"
+ " ,labels(e)[0]='Alert', 'RETURN labels(e)[0] as label, e.id as id, e.sustanciaPeligro as titulo, e.fechaNotificacion_txt as fecha, \"RASFF\" as fuente' \r\n"
+ " ,labels(e)[0]='Science', 'RETURN labels(e)[0] as label, e.id as id, e.titulo as titulo, e.fecha_txt as fecha, \"EFSA\" as fuente' \r\n"
+ " ],\r\n"
+ " 'RETURN \"error\" as label, \"error\" as id, \"error\" as titulo, \"error\" as fecha, \"error\" as fuente',{e:e}) yield value as v\r\n"
+ "return u.eMail as email, v as listaProp, length(p) as score limit 5\r\n"
+ "union\r\n"
+ "match p=(u:User {eMail:$email})-[:INTERESADO_EN]->(:Concept)-[:broader*..3]-(:Concept)<-[:RELACIONADO_CON]-(e)\r\n"
+ "call apoc.case([labels(e)[0]='Lex', 'RETURN labels(e)[0] as label, e.id as id, e.titulo as titulo, e.fechaDisposicion_txt as fecha, \"BOE/EURLEX\" as fuente'\r\n"
+ " ,labels(e)[0]='New', 'RETURN labels(e)[0] as label, e.id as id, e.titulo as titulo, e.fecha_txt as fecha, \"EFSA\" as fuente' \r\n"
+ " ,labels(e)[0]='Alert', 'RETURN labels(e)[0] as label, e.id as id, e.sustanciaPeligro as titulo, e.fechaNotificacion_txt as fecha, \"RASFF\" as fuente' \r\n"
+ " ,labels(e)[0]='Science', 'RETURN labels(e)[0] as label, e.id as id, e.titulo as titulo, e.fecha_txt as fecha, \"EFSA\" as fuente' \r\n"
+ " ],\r\n"
+ " 'RETURN \"error\" as label, \"error\" as id, \"error\" as titulo, \"error\" as fecha, \"error\" as fuente',{e:e}) yield value as v\r\n"
+ "return u.eMail as email, v as listaProp, length(p) as score order by score asc limit 5")
.in(database())
.bind(email).to("email")
.fetchAs(ResultFeed.class)
.mappedBy((typeSystem, record) -> new ResultFeed(record.get("listaProp").asObject()))
.all();
}
(xxController.java)
@GetMapping(value="/feedinicial", produces = MediaType.APPLICATION_JSON_VALUE)
Collection findListaPropFeed(@RequestParam("email") String email) {
return conceptService.findListaPropFeed(email);
}
Thanks, regards
03-29-2021 02:23 PM
So you are now good with using the Neo4jClient
?
This would also be the alternative that I would have advised you to use. The Cypher statement that picks "random" data that cannot really mapped to a domain entity is a good candidate to go this way.
The abstraction levels above (Neo4jTemplate
and Neo4jRepository
) do their mapping work on top of the metadata you are providing for entities that represent real nodes in the graph.
All the sessions of the conference are now available online