Adding Constraints Using Relationship Counts
Just as queries can use expressions that incorporate property values to limit entity type results, they can also use a Relationship count to limit relationship type results. This field sets search criteria based on a quantity (exact, minimum, maximum, range, and so on) tied to the relationship. For example, if you are a financial institution, you might use this feature to identify customers with whom you could increase your business. You could extract customers who have only one account and then determine what other accounts would be appropriate to offer them. The query might look similar to this:
Additionally, you can set this criteria to apply to either end of the connection. Let's say that for the past two years your company has been offering customers free monthly meetings that provide information about retirement accounts. The first month the topic was Simple IRAs, the next month it was Roth IRAs, and so on. For marketing purposes you want to know which meetings had the highest attendance. You also want to know which customers are attending multiple events to determine if you should be advertising this offering to a certain segment of your customer base. This query will return all person and event entities where the person has attended at least four events.
This query will return all person and event entities where an event was attended by at least four persons.