🌊 Streams: Speed up sampling (#207334)

The sampling API can easily get slow because it matches on runtime
fields.

This PR picks the low hanging fruits in speeding it up:
* Not tracking the total hits because that would require to scan all
documents (by default it goes up to 10k)
* Stopping the search after as many matches as requested were found

This is not sufficient as search can still be very slow if condition
matches are rare, as millions of docs might have to be scanned. This can
be improved further in follow-up PRs.
This commit is contained in:
Joe Reuter 2025-01-21 16:58:58 +01:00 committed by GitHub
parent 1e5abbe8ee
commit 49b28eda65
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -187,6 +187,8 @@ export const sampleStreamRoute = createServerRoute({
},
},
],
terminate_after: size,
track_total_hits: false,
size,
};
const results = await scopedClusterClient.asCurrentUser.search({