Context. Circumstellar disks are known to contain a significant mass in dust ranging from micron to centimeter size. Meteorites are evidence that individual grains of those sizes were collected and assembled into planetesimals in the young solar system. Aims. We assess the efficiency of dust collection of a swarm of non-drifting planetesimals {rev with radii ranging from 1 to $10^3$,km and beyond. Methods. We calculate the collision probability of dust drifting in the disk due to gas drag by planetesimal accounting for several regimes depending on the size of the planetesimal, dust, and orbital distance: the geometric, Safronov, settling, and three-body regimes. We also include a hydrodynamical regime to account for the fact that small grains tend to be carried by the gas flow around planetesimals. Results. We provide expressions for the collision probability of dust by planetesimals and for the filtering efficiency by a swarm of planetesimals. For standard turbulence conditions (i.e., a turbulence parameter $alpha=10^{-2}$), filtering is found to be inefficient, meaning that when crossing a minimum-mass solar nebula (MMSN) belt of planetesimals extending between 0.1 AU and 35 AU most dust particles are eventually accreted by the central star rather than colliding with planetesimals. However, if the disk is weakly turbulent ($alpha=10^{-4}$) filtering becomes efficient in two regimes: (i) when planetesimals are all smaller than about 10 km in size, in which case collisions mostly take place in the geometric regime; and (ii) when planetary embryos larger than about 1000 km in size dominate the distribution, have a scale height smaller than one tenth of the gas scale height, and dust is of millimeter size or larger in which case most collisions take place in the settling regime. These two regimes have very different properties: we find that the local filtering efficiency $x_{filter,MMSN}$ scales with $r^{-7/4}$ (where $r$ is the orbital distance) in the geometric regime, but with $r^{-1/4}$ to $r^{1/4}$ in the settling regime. This implies that the filtering of dust by small planetesimals should occur close to the central star and with a short spread in orbital distances. On the other hand, the filtering by embryos in the settling regime is expected to be more gradual and determined by the extent of the disk of embryos. Dust particles much smaller than millimeter size tend only to be captured by the smallest planetesimals because they otherwise move on gas streamlines and their collisions take place in the hydrodynamical regime. Conclusions. Our results hint at an inside-out formation of planetesimals in the infant solar system because small planetesimals in the geometrical limit can filter dust much more efficiently close to the central star. However, even a fully-formed belt of planetesimals such as the MMSN only marginally captures inward-drifting dust and this seems to imply that dust in the protosolar disk has been filtered by planetesimals even smaller than 1 km (not included in this study) or that it has been assembled into planetesimals by other mechanisms (e.g., orderly growth, capture into vortexes). Further refinement of our work concerns, among other things: a quantitative description of the transition region between the hydro and settling regimes; an assessment of the role of disk turbulence for collisions, in particular in the hydro regime; and the coupling of our model to a planetesimal formation model.