Skip to Content

Java Types

The Endee Java SDK provides type-safe classes with builder patterns for full compile-time safety. This page documents all available types, enums, builders, and result classes.

Imports

Import types from the io.endee.client package:

import io.endee.client.Endee; import io.endee.client.Index; import io.endee.client.types.*; import io.endee.client.exception.*;

Enums

Precision

Defines the quantization precision levels for vector storage and search.

public enum Precision { BINARY, INT8D, INT16D, FLOAT16, FLOAT32 }
ValueDescription
BINARYBinary quantization (1-bit) - smallest storage, fastest search
INT8D8-bit integer quantization (default) - balanced performance
INT16D16-bit integer quantization - higher precision
FLOAT1616-bit floating point - good balance
FLOAT3232-bit floating point - highest precision

Usage:

import io.endee.client.types.Precision; CreateIndexOptions options = CreateIndexOptions.builder("my_index", 384) .precision(Precision.INT8D) .build();

SpaceType

Defines the distance metric used for similarity calculations.

public enum SpaceType { COSINE, L2, IP }
ValueDescription
COSINECosine similarity - measures angle between vectors (default)
L2Euclidean distance - measures straight-line distance
IPInner product - measures dot product similarity

Builder Classes

CreateIndexOptions

Options for creating a new index. Uses the builder pattern with required name and dimension parameters.

Builder:

CreateIndexOptions.builder(String name, int dimension) .spaceType(SpaceType) // Default: COSINE .m(int) // Default: 16 .efCon(int) // Default: 128 .precision(Precision) // Default: INT8D .sparseDimension(Integer) // Optional, for hybrid indexes .build()
PropertyTypeRequiredDescription
nameStringYesUnique name for the index (alphanumeric + underscore, max 48 chars)
dimensionintYesVector dimensionality (must match embedding model output, max 10,000)
spaceTypeSpaceTypeNoDistance metric (default: COSINE)
mintNoGraph connectivity parameter (default: 16)
efConintNoConstruction-time quality parameter (default: 128)
precisionPrecisionNoQuantization precision (default: INT8D)
sparseDimensionIntegerNoSparse vector dimension for hybrid indexes

Example:

CreateIndexOptions options = CreateIndexOptions.builder("documents", 384) .spaceType(SpaceType.COSINE) .precision(Precision.INT8D) .m(16) .efCon(128) .build(); client.createIndex(options);

VectorItem

Represents a vector to be upserted into an index. Uses the builder pattern with required id and vector parameters.

Builder:

VectorItem.builder(String id, double[] vector) .meta(Map<String, Object>) // Optional .filter(Map<String, Object>) // Optional .sparseIndices(int[]) // Optional, for hybrid .sparseValues(double[]) // Optional, for hybrid .build()
PropertyTypeRequiredDescription
idStringYesUnique identifier for the vector
vectordouble[]YesDense embedding vector
sparseIndicesint[]NoNon-zero term positions for hybrid search
sparseValuesdouble[]NoWeights for each sparse index
metaMap<String, Object>NoArbitrary metadata map
filterMap<String, Object>NoKey-value pairs for filtering during queries

For hybrid indexes, sparseIndices and sparseValues must have the same length, and values in sparseIndices must be within [0, sparseDimension).

Example:

List<VectorItem> vectors = List.of( VectorItem.builder("doc1", new double[] {0.1, 0.2, 0.3}) .meta(Map.of("title", "Document 1")) .filter(Map.of("category", "tech")) .build(), VectorItem.builder("doc2", new double[] {0.4, 0.5, 0.6}) .sparseIndices(new int[] {10, 50, 200}) .sparseValues(new double[] {0.8, 0.5, 0.3}) .meta(Map.of("title", "Document 2")) .build() ); index.upsert(vectors);

QueryOptions

Options for querying an index. Uses the builder pattern.

Builder:

QueryOptions.builder() .vector(double[]) // Required for dense search .topK(int) // Required .ef(int) // Default: 128 .filter(List<Map<String, Object>>) // Optional .includeVectors(boolean) // Default: false .sparseIndices(int[]) // Optional, for hybrid search .sparseValues(double[]) // Optional, for hybrid search .build()
PropertyTypeRequiredDescription
vectordouble[]NoDense query vector
topKintYesNumber of results to return (max: 512)
filterList<Map<String, Object>>NoFilter conditions (combined with AND)
efintNoSearch quality parameter (default: 128, max: 1024)
includeVectorsbooleanNoInclude vector data in results (default: false)
sparseIndicesint[]NoSparse query positions for hybrid search
sparseValuesdouble[]NoSparse query weights for hybrid search

For hybrid queries, you can provide vector only (dense search), sparseIndices/sparseValues only (sparse search), or all three (hybrid search).

Example:

QueryOptions options = QueryOptions.builder() .vector(new double[] {0.15, 0.25}) .topK(10) .ef(128) .includeVectors(true) .filter(List.of( Map.of("category", Map.of("$eq", "tech")), Map.of("score", Map.of("$range", List.of(80, 100))) )) .build(); List<QueryResult> results = index.query(options);

Result Classes

QueryResult

Represents a single result from a query.

PropertyTypeDescription
idStringVector identifier
similaritydoubleSimilarity score (higher is more similar)
distancedoubleDistance value (1 - similarity)
metaMap<String, Object>Metadata attached to the vector
filterMap<String, Object>Filter fields attached to the vector
normdoubleNormalization factor
vectordouble[]Vector data (only if includeVectors was true)

Getter Methods: getId(), getSimilarity(), getDistance(), getMeta(), getFilter(), getNorm(), getVector()

Example:

List<QueryResult> results = index.query( QueryOptions.builder() .vector(new double[] {0.15, 0.25}) .topK(5) .build() ); for (QueryResult result : results) { System.out.println("ID: " + result.getId()); System.out.println("Similarity: " + result.getSimilarity()); System.out.println("Meta: " + result.getMeta()); }

IndexDescription

Description of an index returned by index.describe().

PropertyTypeDescription
nameStringIndex name
spaceTypeSpaceTypeDistance metric
dimensionintVector dimensionality
sparseDimensionintSparse vector dimension
isHybridbooleanWhether the index supports hybrid search
countlongNumber of vectors in the index
precisionPrecisionQuantization precision
mintGraph connectivity parameter

Getter Methods: getName(), getSpaceType(), getDimension(), getSparseDimension(), isHybrid(), getCount(), getPrecision(), getM()

Example:

IndexDescription info = index.describe(); System.out.println("Index: " + info.getName()); System.out.println("Vectors: " + info.getCount()); System.out.println("Hybrid: " + info.isHybrid()); System.out.println("Precision: " + info.getPrecision());

VectorInfo

Detailed information about a single vector returned by index.getVector().

PropertyTypeDescription
idStringVector identifier
vectordouble[]The full vector data
metaMap<String, Object>Metadata attached to the vector
filterMap<String, Object>Filter fields attached to the vector
normdoubleNormalization factor

Getter Methods: getId(), getVector(), getMeta(), getFilter(), getNorm()

Example:

VectorInfo vectorInfo = index.getVector("doc1"); System.out.println("ID: " + vectorInfo.getId()); System.out.println("Norm: " + vectorInfo.getNorm()); System.out.println("Meta: " + vectorInfo.getMeta()); System.out.println("Vector: " + Arrays.toString(vectorInfo.getVector()));

Exception Classes

EndeeException

Base exception class for all client-side errors (network issues, serialization failures, etc.).

import io.endee.client.exception.EndeeException; try { client.createIndex(options); } catch (EndeeException e) { System.err.println("Client Error: " + e.getMessage()); }

EndeeApiException

Exception for API-specific errors. Extends EndeeException and provides HTTP status code and error body.

MethodReturn TypeDescription
getStatusCode()intHTTP status code
getErrorBody()StringError response body
getMessage()StringError message
import io.endee.client.exception.EndeeApiException; try { client.createIndex(options); } catch (EndeeApiException e) { System.err.println("Status: " + e.getStatusCode()); System.err.println("Body: " + e.getErrorBody()); }

Common HTTP Status Codes:

CodeDescription
400Bad Request - Invalid parameters
401Unauthorized - Invalid or missing authentication
403Forbidden - Insufficient permissions
404Not Found - Index or vector doesn’t exist
409Conflict - Index already exists
500Internal Server Error

Index Class

The Index class is returned by client.getIndex(name) and provides methods for vector operations.

MethodReturn TypeDescription
upsert(List<VectorItem>)StringInsert or update vectors
query(QueryOptions)List<QueryResult>Search for similar vectors
deleteVector(String id)StringDelete a vector by ID
deleteWithFilter(List<Map>)StringDelete vectors by filter
getVector(String id)VectorInfoGet a vector by ID
describe()IndexDescriptionGet index metadata
isHybrid()booleanCheck if index is hybrid

Type Summary

TypeKindDescription
SpaceTypeEnumDistance metric options
PrecisionEnumQuantization precision levels
CreateIndexOptionsBuilder ClassIndex creation parameters
VectorItemBuilder ClassVector for upserting
QueryOptionsBuilder ClassQuery parameters
QueryResultResult ClassSingle query result
IndexDescriptionResult ClassIndex description
VectorInfoResult ClassSingle vector information
EndeeExceptionExceptionClient-side errors
EndeeApiExceptionExceptionAPI-specific errors