i'am thinking about a way to create a distinct pattern result, but i can't come up with a solution.
Lets say there are multiple Students (your school example + students with fore- and surname) with the same surname. Now i want to get all distinct surnames. (duplicate surnames shouldn't match).
Is there a way with incquery or is it impossible at the moment?
Since match results always have SET semantics in the mathematical sense (i.e. matches do not have multiplicities, each combination of pattern parameters is either in the query results exactly once or it doesn't match at all), here every string that is a surname of a Person in the model will appear exactly once in the match set of the pattern.
Note that the above pattern is different from the following one: