In reference to this different but not unrelated question I will borrow the example models.
class Foo(db.Model): bars = db.ListProperty(db.Key)
class Bar(db.Model): pass
If I have a certain Foo entity and I want to get all of the other foo entities also containing a certain bar Key in its bars ListProperty, I would use the following query:
related_foos = Foo.all().filter('bars', bar_entity).fetch(fetch_count)
What about if I want to find all other entities of model kind Foo that have at least N number of matching bar entities? The obvious way to do this with a for-loop would involve drastic inefficiencies, and it might be best to actually change the model itself to make this easier, but it doesn't seem obvious how to do so.