5757import static org .neo4j .gds .PropertyMapping .DEFAULT_VALUE_KEY ;
5858import static org .neo4j .gds .PropertyMapping .PROPERTY_KEY ;
5959import static org .neo4j .gds .RelationshipProjection .AGGREGATION_KEY ;
60+ import static org .neo4j .gds .RelationshipProjection .INDEX_INVERSE_KEY ;
6061import static org .neo4j .gds .RelationshipProjection .ORIENTATION_KEY ;
6162import static org .neo4j .gds .RelationshipProjection .TYPE_KEY ;
6263import static org .neo4j .gds .RelationshipType .ALL_RELATIONSHIPS ;
@@ -849,7 +850,8 @@ private static MinimalObject toMinimalObject(
849850 ElementIdentifier identifier
850851 ) {
851852 MinimalObject properties = toMinimalObject (projection .properties (), true );
852- if (properties .isEmpty () && matchesType (identifier .name , projection )) {
853+
854+ if (properties .isEmpty () && matchesType (identifier .name , projection ) && allDefaults (projection )) {
853855 return MinimalObject .string (identifier .name );
854856 }
855857
@@ -861,10 +863,17 @@ private static MinimalObject toMinimalObject(
861863 if (projection .aggregation () != DEFAULT ) {
862864 value .put (AGGREGATION_KEY , projection .aggregation ().name ());
863865 }
866+ if (projection .indexInverse ()) {
867+ value .put (INDEX_INVERSE_KEY , projection .indexInverse ());
868+ }
864869 properties .toObject ().ifPresent (o -> value .put (PROPERTIES_KEY , o ));
865870 return MinimalObject .map (value );
866871 }
867872
873+ private static boolean allDefaults (RelationshipProjection projection ) {
874+ return projection .orientation () == NATURAL && projection .aggregation () == DEFAULT && !projection .indexInverse ();
875+ }
876+
868877 private static boolean matchesType (String type , RelationshipProjection projection ) {
869878 return projection .orientation () == NATURAL
870879 && projection .aggregation () == DEFAULT
0 commit comments