Configure an index table loading policy

Updated at:

Index table loading policy configuration

An index table loading policy consists of loading policies for multiple groups of index files. Each policy describes how a group of index files is loaded. When loading an index table, the system checks the rules from top to bottom for each file and uses the first matching policy. Paths in these examples are illustrative. Replace description with an existing index name when configuring your instance.

Sample configuration

{
    "load_config":[
        {
            "file_patterns":[
                "_ATTRIBUTE_",
                "/index/title/.*",
                "/index/body/dictionary"
            ],
            "load_strategy":"mmap",
            "lifecycle":"hot",
            "load_strategy_param":{
                "lock":true,
                "partial_lock":true,
                "advise_random":false,
                "slice":4194304,
                "interval":2
            },
            "remote" : false,
            "deploy" : true,
            "warmup_strategy":"sequential"
        },
        {
            "file_patterns":[
                "_SUMMARY_"
            ],
            "load_strategy":"cache",
            "load_strategy_param":{
                "global_cache":false,
                "direct_io":true,
                "cache_size":4096
            },
            "remote" : true,
            "deploy" : false
        },
        {
            "warmup_strategy":"none",
            "file_patterns":[
                ".*"
            ],
            "load_strategy":"mmap",
            "load_strategy_param":{
                "lock":false
            }
        }
    ]
}

Parameters

  • file_patterns: Regular expressions that match index files. For the index table directory structure, see Index file directory structure. A pattern is a regular expression for file names relative to the segment directory. For example, to configure a separate loading policy for the title inverted index, use "/index/title/.*". The index directory contains a title directory, and .* matches all files beneath it. The system provides the following built-in macros to simplify file matching:

    • _ATTRIBUTE_: Equivalent to "/attribute/.*", which represents all forward indexes.

    • _INDEX_: Equivalent to "/index/.*", which represents all inverted indexes.

    • _SUMMARY_: Equivalent to "/summary/", which represents all summary indexes.

  • load_strategy: The loading policy. The main modes are mmap and cache.

  • load_strategy_param: Loading policy parameters.

    • mmap loading policy parameters

      • lock: Whether mmap uses lock mode. Default: false. Lock mode loads indexes into memory and prevents them from being swapped out. It improves query performance but uses more memory.

      • partial_lock: Whether to partially lock inverted indexes. Default: false. Partial locking locks only the first-level dictionary in memory and leaves the second-level dictionary unlocked to save memory.

      • advise_random: Reduces disk read-ahead for mmap. Default: false. If the index is too large to fit entirely in memory, disk I/O often becomes a query bottleneck. Setting this parameter to true can significantly reduce disk reads and improve query performance.

      • slice and interval: Control the index warmup rate. After reading slice bytes, the system sleeps for interval milliseconds. The unit of slice is bytes (B), and the unit of interval is milliseconds (ms). You must configure slice and interval together. Default slice: 4 MB. Default interval: 0 (no throttling).

    • cache loading policy parameters

      • direct_io: Whether to read files using DirectIO. Default: false. DirectIO provides better performance for reading data from SSDs.

      • global_cache: Whether to use a global BlockCache. Default: false. The global BlockCache size is set through an environment variable. This feature is not yet available. We recommend false.

      • cache_size: Applies when global_cache is false. The BlockCache size in MB. Default: 1 MB.

      • block_size: The block size in bytes (B). Default: 4096 B.

  • remote: Whether index files matching file_patterns are read from remote distributed storage. Valid values: true and false. This setting takes effect only when need_read_remote_index is true. If need_read_remote_index is false, remote is forced to false.

  • deploy: Whether index files matching file_patterns must be distributed locally. Valid values: true and false. This setting takes effect only when need_deploy_index is true. If need_deploy_index is false, deploy is forced to false.

  • warmup_strategy: The warmup policy, currently effective only for mmap. Default: none (no warmup). Set to sequential for sequential read warmup.

Examples

mmap loading policy

{
    "load_config":[
        {
            "file_patterns":[
                "/attribute/price/.*",  # Attribute field price
                "/index/title/.*", # Inverted index title
                "/index/body/dictionary", # Dictionary of inverted index body
                "/index/vector/aitheta.*" # Vector index vector
            ],
            "load_strategy":"mmap",
            "load_strategy_param":{
                "lock":true,  # mmap lock mode
                "partial_lock":true, # Partial lock: Lock only the first-level inverted index dictionary.
                "slice":4194304, # During warmup, read 4 MB at a time with a 2 ms interval.
                "interval":2
            },
            "remote" : false, # Do not access remote storage.
            "deploy" : true, # Distribute the index locally.
            "warmup_strategy":"sequential" # Sequential warmup
        },
        {
            "file_patterns":[
                "/attribute/tags", # Attribute field tag
                "/index/description/.*"  # Inverted index description
            ],
            "load_strategy":"mmap",
            "load_strategy_param":{
                "lock":false,
            },
            "remote" : false,
            "deploy" : true,
            "warmup_strategy":"none"
        }
    ]
}

cache loading policy

{
    "load_config":[
        {
            "file_patterns":[
                "_ATTRIBUTE_" # All attribute fields
            ],
            "load_strategy":"cache",
            "load_strategy_param":{
                "global_cache":false, # Do not use the global cache.
                "direct_io":true, # Read files using DirectIO.
                "cache_size":20480 # Cache size: 20 GB.
            },
            "remote" : false, # Do not access remote storage.
            "deploy" : true # Distribute the index locally.
        },
        {
            "file_patterns":[
                "/summary/data"  # The data file of the summary index.
            ],
            "load_strategy":"cache",
            "load_strategy_param":{
                "global_cache":false,
                "direct_io":true,
                "cache_size":4096
            },
            "remote" : false,
            "deploy" : true
        },
        {
            "warmup_strategy":"none",
            "file_patterns":[
                ".*"
            ],
            "load_strategy":"mmap",
            "load_strategy_param":{
                "lock":false
            }
        }
    ]
}

Storage-computing separation

# Storage-computing separation requires need_read_remote_index to be true.
{
    "load_config":[
        {
            "file_patterns":[
                "/index/title/.*" # Inverted index title
            ],
            "load_strategy":"mmap",
            "load_strategy_param":{
                "lock":true,  # mmap lock mode
                "partial_lock":true, # Partial lock: Lock only the first-level inverted index dictionary.
                "slice":4194304, # During warmup, read 4 MB at a time with a 2 ms interval.
                "interval":2
            },
            "remote" : false, # Do not access remote storage.
            "deploy" : true, # Distribute the index locally.
            "warmup_strategy":"sequential" # Sequential warmup
        },
        {
            "file_patterns":[
                "_ATTRIBUTE_" # All attribute fields
            ],
            "load_strategy":"cache",
            "load_strategy_param":{
                "global_cache":false, # Do not use the global cache.
                "direct_io":true, # Read files using DirectIO.
                "cache_size":20480 # Cache size: 20 GB.
            },
            "remote" : true, # Access remote storage.
            "deploy" : false # Do not distribute the index locally.
        },
        {
            "file_patterns":[
                "/summary/data"  # The data file of the summary index.
            ],
            "load_strategy":"cache",
            "load_strategy_param":{
                "global_cache":false,
                "direct_io":true,
                "cache_size":4096
            },
            "remote" : true, # Access remote storage.
            "deploy" : false # Do not distribute the index locally.
        },
        {
            "warmup_strategy":"none",
            "file_patterns":[
                ".*"
            ],
            "load_strategy":"mmap",
            "load_strategy_param":{
                "lock":false
            }
        }
    ]
}

Index file directory structure

  |-- generation_0
      |-- partition_0_65535
          |-- index_format_version
          |-- index_partition_meta
          |-- schema.json
          |-- segment_0
              |-- attribute
                  `--attribute_name
                     `--data   
              |-- deletionmap
              |-- deploy_index
              |-- index
                 `--index_name
                    |-- bitmap_dictionary
                    |-- bitmap_posting
                    |-- dictionary
                    `-- posting
                  `--vector_index_name
                    |-- aitheta.index
                  	|-- aitheta.index.addr
              |-- summary
                	|-- data
                	|-- offset
              `-- segment_info
          |-- adaptive_bitmap__meta
              |--deploy_index
              |--dictionary_name
          |-- truncate_meta
              |-- deploy_index
              `-- truncate_meta_file 
          `-- version.0

Name

Description

generation

generation_x identifies different versions of a full index in the engine.

partition

A partition is the basic unit of indexes loaded by a searcher. Excessive data in a partition reduces searcher performance. Online data is generally split into multiple partitions to maintain retrieval efficiency for each searcher.

segment

A segment is the basic component of an index. It contains the inverted and forward index structures of documents. Each index builder dump generates a segment. Multiple segments can be combined using a merge policy. The version file specifies which segments in a partition are available.

index

The basic unit of an inverted index.

attribute

The basic unit of a forward index.

deletionmap

Records of deleted documents.

index_format_version

Index version information, used to check whether index files meet binary requirements.

index_partition_meta

Global sorting information, including sort fields and ascending or descending order.

schema.json

The index configuration file. It mainly records fields, index, attribute, and summary information. The engine uses this file to load indexes.

version.0

The version file. It mainly records the segments that the engine must load in the current partition and the timestamp of the latest document. During real-time builds, the engine uses the incremental version timestamp to filter out old original documents.

segment_info

Segment metadata. It records the document count, whether the segment has been merged, locator information, and the latest document timestamp.

dictionary

The dictionary of an inverted index.

posting

The posting list file of an inverted index.

bitmap_dictionary

The dictionary of high-frequency terms if the bitmap high-frequency term feature is enabled.

bitmap_posting

The posting lists of high-frequency terms if the bitmap high-frequency term feature is enabled.

aitheta.index

The vector index file.

aitheta.index.addr

Vector index metadata.