Skip to content
On this page

Memory Allocation

The book "Gulliver's Travels Swift Jonathan 1726" was fully indexed for the examples below.

The most memory-optimized meaningful setting will allocate just 1.2 Mb for the whole book indexed! This is probably the most tiny memory footprint you will get from a search library.

js
import { encode } from "./lang/latin/extra.js";

index = new Index({
  encode: encode,
  tokenize: "strict",
  optimize: true,
  resolution: 1,
  minlength: 3,
  fastupdate: false,
  context: false,
});

Memory Consumption

The book "Gulliver's Travels" (Swift Jonathan 1726) was completely indexed for this test:


Compare Impact of Memory Allocation

by default a lexical index is very small:
depth: 0, bidirectional: 0, resolution: 3, minlength: 0 => 2.1 Mb

a higher resolution will increase the memory allocation:
depth: 0, bidirectional: 0, resolution: 9, minlength: 0 => 2.9 Mb

using the contextual index will increase the memory allocation:
depth: 1, bidirectional: 0, resolution: 9, minlength: 0 => 12.5 Mb

a higher contextual depth will increase the memory allocation:
depth: 2, bidirectional: 0, resolution: 9, minlength: 0 => 21.5 Mb

a higher minlength will decrease memory allocation:
depth: 2, bidirectional: 0, resolution: 9, minlength: 3 => 19.0 Mb

using bidirectional will decrease memory allocation:
depth: 2, bidirectional: 1, resolution: 9, minlength: 3 => 17.9 Mb

enable the option "fastupdate" will increase memory allocation:
depth: 2, bidirectional: 1, resolution: 9, minlength: 3 => 6.3 Mb

Full Comparison Table

Every search library is constantly in competition with these 4 properties:

  1. Memory Allocation
  2. Performance
  3. Matching Capabilities
  4. Relevance Order (Scoring)

FlexSearch provides you many parameters you can use to adjust the optimal balance for your specific use-case.

ModifierMemory Impact *Performance Impact **Matching Impact **Scoring Impact **
resolution+1 (per level)+1 (per level)0+2 (per level)
depth+4 (per level)-1 (per level)-10 + depth+10
minlength-2 (per level)+2 (per level)-3 (per level)+2 (per level)
bidirectional-20+3-1
fastupdate+1+10 (update, remove)00
optimize: true-7-10-3
encoder: "icase"0000
encoder: "simple"-2-1+20
encoder: "advanced"-3-2+40
encoder: "extra"-5-5+60
encoder: "soundex"-6-2+80
tokenize: "strict"0000
tokenize: "forward"+3-2+50
tokenize: "reverse"+5-4+70
tokenize: "full"+8-5+100
document index+3 (per field)-1 (per field)00
document tags+1 (per tag)-1 (per tag)00
store: true+5 (per document)000
store: [fields]+1 (per field)000
cache: true+10+1000
cache: 100+1+900
type of ids: number0000
type of ids: string+3-300
  • range from -10 to 10, lower is better (-10 => big decrease, 0 => unchanged, +10 => big increase)
    ** range from -10 to 10, higher is better