Set How Much Memory Kept Filters May Take

Every filter a search uses is kept between searches, so a filter used again is ready at once. The kept filters are limited in megabytes, 256 by default for each dataset. When they take more, the least recently used are let go. 0 keeps none: every filter is made again for each search.

A filter that matches many documents takes more room than one that matches few: on a catalogue of 650,000 records a wide price range takes about 80 KB, a value filter on a field with many values about 1 KB. Ranges with free bounds (a price slider, a date picker) make a new filter for each pair of bounds, so they are what fills the cache.

In the console

A dataset's Options → Memory shows what its kept filters take and the limit, for example 236 MB of 256 MB, 5,266 filters. Edit sets a new limit. A dataset that is loaded is rebuilt in the background with it, and searches go on meanwhile; one that is asleep takes it when it is next loaded. Admin → Datasets shows the same for every dataset, and an admin can change it there.

The limit is given when the engine is made:

csharp
var engine = new SearchEngine("indx-developer.license", filterCacheMB: 512);

// ...load, index and search...

var status = engine.Status;
Console.WriteLine(
quot;{status.FilterCacheFilters} filters, {status.FilterCacheBytes / 1024 / 1024} MB of {status.FilterCacheLimitBytes / 1024 / 1024} MB");

To change it, make a new engine with the new limit and load it again.

Many values in one filter

To filter on a set of values (a customer's 500 categories, a list of item numbers), make one IN filter, not an OR of a value filter per value: it is made in one go, and it is one kept filter rather than many.

csharp
var categories = engine.CreateInFilter("categories", customerCategories, out _);

Over HTTP: POST /api/teams/{teamName}/datasets/{dataSetName}/filters/in. See Filter or Boost with Multiple Conditions.