User Define functions

I have a java function that returns a List. The argument to this functions is local defined List used for testing. When I run this function in Neo4j desktop, it uses the local variable value instead the parameter passed from Neo4j.

Can you share your code, please?

1 Like

Java function

static String[] localStr = {"str1", "str2"};
Static List<String> listArgs=Arrays.asList(localStr );
  @UserFunction
  public String generateUniqueStrings(
  @Name("listArgs")List<String> listArgs){
       //..Some processing and local def of List of strings to be
        
       return List of Strings.

Cypher code

Match(s) where s.name contains("str")
return distinct(packageName.generateUniqueStrings(["This is a string", "This is a string", "This"])

Neo4j returns ["str1", "str2"]

What is the purpose of your two static variables? You also have a name clash with one of them and your method parameter.

Anyways, it would helpful it you provide the body of the method, so we can see what you return and how it was calculated.