Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
04-14-2021 04:04 PM
Hi,
I have to create a query with . . . WHERE labels(e) in [["Lex"],['Alert']] . . .
My code is:
public Collection<ResultFeed> findText(String email, String texto, List<String> label_list) {
return this.neo4jClient
.query("CALL db.index.fulltext.queryNodes('IdxLabels', $texto +'~2')\r\n"
+ "YIELD node, score\r\n"
+ "with node as label, score order by score desc limit 100\r\n"
+ "match (label)<-[:prefLabel]-(c:Concept)\r\n"
+ "with c, max(score) as maxScore\r\n"
+ "order by maxScore desc limit 10\r\n"
+ "call {\r\n"
+ "match p=(e)-[:RELACIONADO_CON]->(c)\r\n"
+ "WHERE labels(e) in $label_list \r\n"
. . .
.bind(label_list).to("label_list")
and the query is created with:
:params {texto: 'aditivos', label_list: ['Lex', 'Alert'],
but the correct format will be: [["Lex"],['Alert']]
How can I solve this format problem?
Thanks in advance
Regards
04-15-2021 01:41 AM
What about changing your WHERE
clause to something like:
WHERE ALL(label IN LABELS(e) WHERE label IN $label_list)
and $label_list
can be ["label1", "label2"]
.
04-15-2021 02:58 PM
Sure, it's a quick fix
works correctly
Thank you Florent
Regards.
04-15-2021 10:32 PM
You could also provide a list of lists as a parameter:
try (var session = driver.session()) {
session.run("CREATE (:Thing:Toy), (:Thing:Food), (:Thing:Something)").consume();
}
List<List<String>> labelList = List.of(List.of("Thing", "Toy"), List.of("Thing", "Food"));
Collection<Map<String, Object>> things = neo4jClient.query("MATCH (n:Thing) WHERE labels(n) in $label_list return n")
.bind(labelList).to("label_list")
.fetch().all();
assertThat(things).hasSize(2);
All the sessions of the conference are now available online