Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Lance format Lance Java IndexParams

From Leeroopedia


Knowledge Sources
Domains Java_SDK, Indexing
Last Updated 2026-02-08 19:33 GMT

Overview

Description

IndexParams is a Java class in the org.lance.index package that serves as a top-level container for index creation parameters. It holds an optional VectorIndexParams and an optional ScalarIndexParams, allowing it to represent parameters for either a vector index, a scalar index, or both. The class is immutable and follows the Builder pattern.

Usage

IndexParams is used as a required input to IndexOptions when creating an index on a dataset. Callers construct it via IndexParams.builder(), setting either vector or scalar parameters (or both) depending on the index type being created.

Code Reference

Source Location

java/src/main/java/org/lance/index/IndexParams.java

Signature

public class IndexParams {
    public static Builder builder();

    public Optional<VectorIndexParams> getVectorIndexParams();
    public Optional<ScalarIndexParams> getScalarIndexParams();

    public static class Builder {
        public Builder setVectorIndexParams(VectorIndexParams vectorIndexParams);
        public Builder setScalarIndexParams(ScalarIndexParams scalarIndexParams);
        public IndexParams build();
    }
}

Import

import org.lance.index.IndexParams;

I/O Contract

Builder Inputs
Parameter Type Required Default Description
vectorIndexParams VectorIndexParams No Optional.empty() Parameters for creating a vector index
scalarIndexParams ScalarIndexParams No Optional.empty() Parameters for creating a scalar index
Accessor Outputs
Method Return Type Description
getVectorIndexParams() Optional<VectorIndexParams> Vector index parameters, if set
getScalarIndexParams() Optional<ScalarIndexParams> Scalar index parameters, if set

Usage Examples

import org.lance.index.IndexParams;
import org.lance.index.vector.VectorIndexParams;
import org.lance.index.scalar.ScalarIndexParams;
import org.lance.index.scalar.BTreeIndexParams;
import org.lance.index.DistanceType;

// Create IndexParams for a vector index
VectorIndexParams vectorParams = VectorIndexParams.ivfFlat(128, DistanceType.L2);
IndexParams vectorIndexParams = IndexParams.builder()
    .setVectorIndexParams(vectorParams)
    .build();

// Create IndexParams for a scalar BTree index
ScalarIndexParams scalarParams = BTreeIndexParams.builder().build();
IndexParams scalarIndexParams = IndexParams.builder()
    .setScalarIndexParams(scalarParams)
    .build();

// Inspect via toString
System.out.println(vectorIndexParams);
// IndexParams{vectorIndexParams=..., scalarIndexParams=null}

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment