Todos os produtos
Search
Central de documentação

DashVector:Definições de tipos de dados do DashVector

Última atualização: Jun 29, 2026

O DashVector usa os seguintes tipos de dados para representar documentos, coleções e seus estados. Esta página apresenta as definições em Python e Java para cada tipo.

Doc

Um Doc é um registro individual em uma coleção do DashVector. Ele associa um vetor a um ID e a metadados opcionais:

{
    "id": "doc-001",
    "vector": [0.1, 0.2, 0.3, 0.4],
    "sparse_vector": {"10": 0.5, "25": 0.8},
    "fields": {"category": "article", "year": 2024},
    "score": 0.95
}

Python

@dataclass(frozen=True)
class Doc(object):
    id: str                                            # The primary key.
    vector: Union[List[int], List[float], np.ndarray]  # The vector.
    sparse_vector: Optional[Dict[int, float]] = None   # The sparse vector.
    fields: Optional[FieldDataDict] = None             # The custom fields in the document.
    score: float = 0.0                                 # The similarity between vectors.

Java

@Data
@Builder
public class Doc {
  // The primary key.
  @NonNull private String id;
  // The vector.
  @NonNull private Vector vector;
  // The sparse vector.
  private TreeMap<Integer, Float> sparseVector;
  // The custom fields in the document.
  @Builder.Default private Map<String, Object> fields = new HashMap<>();
  // The similarity between vectors.
  private float score;

  public void addField(String key, String value) {
    this.fields.put(key, value);
  }

  public void addField(String key, Integer value) {
    this.fields.put(key, value);
  }

  public void addField(String key, Float value) {
    this.fields.put(key, value);
  }

  public void addField(String key, Boolean value) {
    this.fields.put(key, value);
  }
}

Referência de campos

Campo

Tipo (Python)

Tipo (Java)

Descrição

id

str

String

Chave primária que identifica exclusivamente um documento.

vector

Union[List[int], List[float], np.ndarray]

Vector

Vetor denso.

sparse_vector

Optional[Dict[int, float]]

TreeMap<Integer, Float>

Vetor esparso.

fields

Optional[FieldDataDict]

Map<String, Object>

Pares chave-valor personalizados para filtragem de metadados.

score

float (padrão: 0.0)

float

Similaridade entre vetores.

Tipos de dados de campo compatíveis

Tipo

Python

Java

String

str

String

Inteiro

int

Integer

Float

float

Float

Booleano

bool

Boolean

CollectionMeta

CollectionMeta descreve a configuração de uma coleção: nome, dimensões do vetor, métrica de distância, esquema de campos e layout de partições.

Python

@dataclass(frozen=True)
class CollectionMeta(object):
    name: str                      # The name of the collection.
    dimension: int                 # The number of vector dimensions.
    dtype: str                     # The data type of the vector. Valid values: float and int.
    metric: str                    # The distance metric. Valid values: euclidean, dotproduct, and cosine.
    status: Status                 # The status of the collection.
    fields: Dict[str, str]         # The fields in the collection. Supported data types of fields: float, bool, int, and str.
    partitions: Dict[str, Status]  # The information about the partitions in the collection.

Java

@Getter
public class CollectionMeta {
  // The name of the collection.
  private final String name;
  // The number of vector dimensions.
  private final int dimension;
  // The data type of the vector. Valid values: float and int.
  private final CollectionInfo.DataType dataType;
  // The distance metric. Valid values: euclidean, dotproduct, and cosine.
  private final CollectionInfo.Metric metric;
  // The status of the collection.
  private final String status;
  // The fields in the collection. Supported data types of fields: float, bool, int, and str.
  private final Map<String, FieldType> fieldsSchema;
  // The information about the partitions in the collection.
  private final Map<String, Status> partitionStatus;

  public CollectionMeta(CollectionInfo collectionInfo) {
    this.name = collectionInfo.getName();
    this.dimension = collectionInfo.getDimension();
    this.dataType = collectionInfo.getDtype();
    this.metric = collectionInfo.getMetric();
    this.status = collectionInfo.getStatus().name();
    this.fieldsSchema = collectionInfo.getFieldsSchemaMap();
    this.partitionStatus = collectionInfo.getPartitionsMap();
  }
}

Referência de campos

Campo

Tipo (Python)

Tipo (Java)

Descrição

name

str

String

Nome da coleção.

dimension

int

int

Número de dimensões do vetor.

dtype

str

CollectionInfo.DataType

Tipo de dados dos vetores na coleção. Valores válidos: float, int.

metric

str

CollectionInfo.Metric

Métrica de distância para busca por similaridade. Valores válidos: euclidean, dotproduct, cosine.

status

Status

String

Status atual da coleção. Consulte Status.

fields

Dict[str, str]

Map<String, FieldType>

Esquema de campos personalizados definidos para a coleção. Tipos de dados compatíveis: float, bool, int, str.

partitions

Dict[str, Status]

Map<String, Status>

Mapeamento dos nomes das partições aos respectivos status atuais.

Métricas de distância

Métrica

Valor na API

Distância euclidiana

euclidean

Produto escalar

dotproduct

Similaridade de cosseno

cosine

Tipos de dados de vetor

Tipo de dado

Valor na API

Float

float

Inteiro

int

CollectionStats

CollectionStats informa a contagem de documentos e o progresso de criação do índice de uma coleção.

Python

@dataclass(frozen=True)
class CollectionStats(object):
    total_doc_count: int                    # The total number of documents inserted into the collection.
    index_completeness: float               # The completeness of data insertion into the collection.
    partitions: Dict[str, PartitionStats]   # The information about the partitions in the collection.

Java

@Getter
public class CollectionStats {
  // The total number of documents inserted into the collection.
  private final long totalDocCount;
  // The completeness of data insertion into the collection.
  private final float indexCompleteness;
  // The information about the partitions in the collection.
  private final Map<String, PartitionStats> partitions;

  public CollectionStats(StatsCollectionResponse.CollectionStats collectionStats) {
    this.totalDocCount = collectionStats.getTotalDocCount();
    this.indexCompleteness = collectionStats.getIndexCompleteness();
    this.partitions = new HashMap<>();
    collectionStats
        .getPartitionsMap()
        .forEach((key, value) -> this.partitions.put(key, new PartitionStats(value)));
  }
}

Referência de campos

Campo

Tipo (Python)

Tipo (Java)

Descrição

total_doc_count

int

long

Total de documentos inseridos na coleção.

index_completeness

float

float

Integridade da inserção de dados na coleção.

partitions

Dict[str, PartitionStats]

Map<String, PartitionStats>

Mapeamento dos nomes das partições às respectivas estatísticas. Consulte PartitionStats.

PartitionStats

PartitionStats informa a contagem de documentos de uma única partição em uma coleção.

Python

@dataclass(frozen=True)
class PartitionStats(object):
    total_doc_count: int                    # The total number of documents in the partition.

Java

@Getter
public class PartitionStats {
  // The total number of documents in the partition.
  private final long totalDocCount;

  public PartitionStats(com.aliyun.dashvector.proto.PartitionStats partitionStats) {
    this.totalDocCount = partitionStats.getTotalDocCount();
  }
}

Referência de campos

Campo

Tipo (Python)

Tipo (Java)

Descrição

total_doc_count

int

long

Total de documentos na partição.

Status

A enumeração Status define os estados do ciclo de vida de uma coleção ou partição.

class Status(IntEnum):
    INITIALIZED = 0                        # The collection or partition is being created.
    SERVING = 1                            # The collection or partition is in service.
    DROPPING = 2                           # The collection or partition is being deleted.
    ERROR = 3                              # The collection or partition is abnormal.

Valor

Inteiro

Descrição

INITIALIZED

0

Criação da coleção ou partição em andamento.

SERVING

1

Coleção ou partição em serviço.

DROPPING

2

Exclusão da coleção ou partição em andamento.

ERROR

3

Erro encontrado na coleção ou partição.

Aliases de tipo (Python)

O SDK do Python define os seguintes aliases de tipo:

long = NewType("long", int)

FieldDataType = Union[long, str, int, float, bool]

FieldDataDict = Dict[str, FieldDataType]

VectorValueType = Union[List[int], List[float], np.ndarray]

Alias

Definição

Descrição

long

NewType("long", int)

Tipo inteiro estendido.

FieldDataType

Union[long, str, int, float, bool]

Tipos de valores aceitos para campos personalizados de documentos.

FieldDataDict

Dict[str, FieldDataType]

Tipo do parâmetro fields em Doc.

VectorValueType

Union[List[int], List[float], np.ndarray]

Tipos aceitos para o parâmetro vector em Doc.