well-typed / full-text-search

An in-memory full text search engine library. It lets you run full-text queries on a collection of your documents.
Other
47 stars 5 forks source link

Avoid computing union of large DocIdSets in auto-suggest queries #13

Closed adamgundry closed 1 year ago

adamgundry commented 1 year ago

Auto-suggest queries impose a pre-filter limit to constrain the number of documents that may be scored (since scoring is expensive). However this is imposed only after computing the set of all documents, via the union of various DocIdSets. If these constituent DocIdSets are very large, computing their union may itself be unreasonably expensive and cause large amounts of allocation (before potentially hitting the limit and returning no results anyway).

This patch detects such cases early: