View Source Qdrant.Api.Http.Collections (Qdrant v0.0.8)

Qdrant API Collections.

Collections are searchable collections of points.

Link to this section Summary

Functions

Get cluster information for a collection See more on qdrant

Get detailed information about specified existing collection. See more on qdrant

Create new collection with given parameters. See more on qdrant

Download specified snapshot from a collection as a file. See more on qdrant

Get list of all aliases for a collection See more on qdrant

Get list of snapshots for a collection. See more on qdrant

Get list name of all existing collections. See more on qdrant

Update aliases of the collections See more on qdrant

Link to this section Types

@type alias_actions_list() :: %{
  actions: [delete_alias() | create_alias() | rename_alias()]
}
@type cluster_update_body() ::
  %{move_shard: shadred_operation_params()}
  | %{replicate_shard: shadred_operation_params()}
  | %{abort_transfer: shadred_operation_params()}
  | %{drop_replica: drop_replica_params()}
@type consistency() :: non_neg_integer() | :majority | :quorum | :all
@type create_alias() :: %{alias_name: String.t(), collection_name: String.t()}
Link to this type

create_collection_body()

View Source
@type create_collection_body() :: %{
  vectors: %{
    size: non_neg_integer(),
    distance: String.t(),
    hnsw_config: hnsw_config() | nil,
    quantization_config: quantization_config() | nil
  },
  shard_number: non_neg_integer() | nil,
  replication_factor: pos_integer(),
  write_consistency_factor: non_neg_integer() | nil,
  on_disk_payload: boolean() | nil,
  hnsw_config: hnsw_config() | nil,
  wal_config: %{
    wal_capacity_mb: pos_integer() | nil,
    wal_segments_ahead: pos_integer() | nil
  },
  optimizers_config: optimizers_config() | nil,
  init_from: String.t() | nil,
  quantization_config: quantization_config() | nil
}
@type delete_alias() :: %{alias_name: String.t()}
@type drop_replica_params() :: %{shard_id: integer(), peer_id: integer()}
@type extended_point_id() :: [non_neg_integer() | String.t()]
@type field_index() :: %{field_name: String.t(), field_schema: field_schema()}
@type field_schema() :: %{
  type: index_body_type(),
  tokenizers: tokenizer_type(),
  min_token_len: non_neg_integer(),
  max_token_len: non_neg_integer(),
  lowercase: boolean()
}
@type hnsw_config() :: %{
  m: non_neg_integer() | nil,
  ef_construct: non_neg_integer() | nil,
  full_scan_threshold: non_neg_integer() | nil,
  max_indexing_threads: non_neg_integer() | nil,
  on_disk: boolean() | nil,
  payload_m: non_neg_integer() | nil
}
@type index_body_type() :: :keyword | :integer | :float | :geo | :text
@type optimizers_config() :: %{
  deleted_threshold: float() | nil,
  vacuum_min_vector_number: non_neg_integer() | nil,
  default_segment_number: non_neg_integer() | nil,
  max_segment_size: non_neg_integer() | nil,
  memmap_threshold: non_neg_integer() | nil,
  indexing_threshold: non_neg_integer() | nil,
  flush_interval_sec: non_neg_integer() | nil,
  max_optimization_threads: pos_integer() | nil
}
@type ordering() :: :weak | :medium | :strong
@type point() :: %{
  id: non_neg_integer() | String.t(),
  vector: [float()],
  payload: map()
}
@type quantization_config() :: %{
  scalar: %{type: String.t(), quantile: float(), always_ram: boolean()}
}
@type rename_alias() :: %{old_alias_name: String.t(), new_alias_name: String.t()}
Link to this type

shadred_operation_params()

View Source
@type shadred_operation_params() :: %{
  shard_id: integer(),
  from_peer_id: integer(),
  to_peer_id: integer()
}
@type tokenizer_type() :: :prefix | :whitespace | :word
Link to this type

update_collection_body()

View Source
@type update_collection_body() :: %{
  optimizers_config: optimizers_config(),
  params: %{
    replication_factor: pos_integer() | nil,
    write_consistency_factor: pos_integer() | nil
  }
}
@type vector() :: [float()] | %{name: String.t(), vector: [float()]}
Link to this type

with_payload_interface()

View Source
@type with_payload_interface() ::
  boolean() | [String.t()] | %{include: String.t(), exclude: String.t()}

Link to this section Functions

Link to this function

collection_cluster_info(collection_name)

View Source
@spec collection_cluster_info(String.t()) :: {:ok, map()} | {:error, any()}

Get cluster information for a collection See more on qdrant

path-parameters

Path parameters

  • collection_name required : Name of the collection to retrieve the cluster info for

example

Example

iex> Qdrant.collection_cluster_info("collection_name")
{:ok, %{"status" => "ok", "time" => 0, "result" => %{"operation_id" => 42, status: "acknowledged"} }}}}
Link to this function

collection_info(collection_name)

View Source
@spec collection_info(String.t()) :: {:ok, map()} | {:error, any()}

Get detailed information about specified existing collection. See more on qdrant

path-parameters

Path parameters

  • collection_name required: name of the collection

example

Example

iex> Qdrant.Api.Http.Collections.collection_info("my_collection")
{:ok, %Tesla.Env{status: 200,
  body: %{
      "result" => %{
        "collection_type" => "Flat",
        "name" => "my_collection",
        "points_count" => 0,
        "vectors_count" => 0
      },
      "status" => "ok",
      "time" => 2.043e-6
    }
  }
}
Link to this function

create_collection(name, body, timeout \\ nil)

View Source
@spec create_collection(String.t(), create_collection_body(), integer() | nil) ::
  {:ok, map()} | {:error, any()}

Create new collection with given parameters. See more on qdrant

path-parameters

Path parameters

  • name required : Name of the new collection

query-parameters

Query parameters

  • timeout optional : Wait for operation commit timeout in seconds. If timeout is reached - request will return with service error.

request-body-schema

Request body schema

  • vectors required: Vector params separator for single and multiple vector modes. Single mode: %{size: 128, distance: "Cosine"} or multiple mode: %{default: {size: 128, distance: "Cosine"}}

  • shard_number optional: null or positive integer Default: null. Number of shards in collection. Default is 1 for standalone, otherwise equal to the number of nodes Minimum is 1.

  • replication_factor optional: null or positive integer Default: null. Number of shards replicas. Default is 1 Minimum is 1

  • write_consistency_factor optional: null or positive integer Default: null. Defines how many replicas should apply the operation for us to consider it successful. Increasing this number will make the collection more resilient to inconsistencies, but will also make it fail if not enough replicas are available. Does not have any performance impact.

  • on_disk_payload optional: boolean or null Default: null. If true - point's payload will not be stored in memory. It will be read from the disk every time it is requested. This setting saves RAM by (slightly) increasing the response time. Note: those payload values that are involved in filtering and are indexed - remain in RAM.

  • hnsw_config optional: Custom params for HNSW index. If none - values from service configuration file are used.

  • wal_config optional: Custom params for WAL. If none - values from service configuration file are used.

  • optimizers_config optional: Custom params for Optimizers. If none - values from service configuration file are used.

  • init_from optional: null or string Default: null. Specify other collection to copy data from.

  • quantization_config optional: Default: null. m Quantization parameters. If none - quantization is disabled.

Link to this function

create_collection_snapshot(collection_name, wait \\ true)

View Source
@spec create_collection_snapshot(String.t(), boolean()) ::
  {:ok, map()} | {:error, any()}

Create a new snapshot for a collection. See more on qdrant

path-parameters

Path parameters

  • collection_name required : Name of the collection to create a snapshot for

query-parameters

Query parameters

  • wait optional : If true, wait for changes to actually happen. If false - let changes happen in background. Default is true.
Link to this function

create_field_index(collection_name, body, wait \\ false, ordering \\ nil)

View Source
@spec create_field_index(String.t(), field_index(), boolean(), ordering() | nil) ::
  {:ok, map()} | {:error, any()}

Create index for field in collection See more on qdrant

path-parameters

Path parameters

  • collection_name required : Name of the collection

query-parameters

Query parameters

  • wait optional : If true, wait for changes to actually happen

  • ordering optional : Define ordering guarantees for the operation

request-body-schema

Request body schema

  • field_name required : Name of the field to index

  • field_schema required : Type of the field to index

example

Example

iex> Qdrant.create_field_index("collection_name", %{field_name: "field_name", field_schema: "field_schema"})
{:ok, %{"status" => "ok", "time" => 0, "result" => %{"operation_id" => 42, status: "acknowledged"} }}}}
Link to this function

delete_collection(collection_name, timeout \\ nil)

View Source
@spec delete_collection(String.t(), integer() | nil) :: {:ok, map()} | {:error, any()}

Drop collection and all associated data See more on qdrant

path-parameters

Path parameters

  • collection_name required : Name of the collection to delete

query-parameters

Query parameters

  • timeout optional : Wait for operation commit timeout in seconds. If timeout is reached - request will return with service error.
Link to this function

delete_collection_snapshot(collection_name, snapshot_name, wait \\ true)

View Source
@spec delete_collection_snapshot(String.t(), String.t(), boolean()) ::
  {:ok, map()} | {:error, any()}

Delete snapshot for a collection See more on qdrant

path-parameters

Path parameters

  • collection_name required : Name of the collection to delete a snapshot for

  • snapshot_name required : Name of the snapshot to delete

query-parameters

Query parameters

  • wait optional : If true, wait for changes to actually happen. If false - let changes happen in background. Default is true.
Link to this function

delete_field_index(collection_name, field_name, wait \\ false, ordering \\ nil)

View Source
@spec delete_field_index(String.t(), String.t(), boolean(), ordering() | nil) ::
  {:ok, map()} | {:error, any()}

Delete index for field in collection See more on qdrant

path-parameters

Path parameters

  • collection_name required : Name of the collection

  • field_name required : Name of the field where to delete the index

query-parameters

Query parameters

  • wait optional : If true, wait for changes to actually happen

  • ordering optional : Define ordering guarantees for the operation

example

Example

iex> Qdrant.delete_field_index("collection_name", "field_name")
{:ok, %{"status" => "ok", "time" => 0, "result" => %{"operation_id" => 42, status: "acknowledged"} }}}}
Link to this function

download_collection_snapshot(collection_name, snapshot_name)

View Source
@spec download_collection_snapshot(String.t(), String.t()) ::
  {:ok, map()} | {:error, any()}

Download specified snapshot from a collection as a file. See more on qdrant

path-parameters

Path parameters

  • collection_name required : Name of the collection to download a snapshot for

  • snapshot_name required : Name of the snapshot to download

Link to this function

list_collection_aliases(collection_name)

View Source
@spec list_collection_aliases(String.t()) :: {:ok, map()} | {:error, any()}

Get list of all aliases for a collection See more on qdrant

path-parameters

Path parameters

  • collection_name required : Name of the collection to retrieve the aliases for

example

Example

iex> Qdrant.list_collection_aliases("collection_name")
{:ok, %{"status" => "ok", "time" => 0, "result" => %{"operation_id" => 42, status: "acknowledged"} }}}}
Link to this function

list_collection_snapshots(collection_name)

View Source
@spec list_collection_snapshots(String.t()) :: {:ok, map()} | {:error, any()}

Get list of snapshots for a collection. See more on qdrant

@spec list_collections() :: {:ok, Tesla.Env.t()} | {:error, any()}

Get list name of all existing collections. See more on qdrant

example

Example

iex> Qdrant.Api.Http.Collections.list_collections()
{:ok, %Tesla.Env{status: 200,
  body: %{
      "result" => %{"collections" => [...]},
      "status" => "ok",
      "time" => 2.043e-6
    }
  }
}
Link to this function

update_aliases(body, timeout \\ nil)

View Source
@spec update_aliases(alias_actions_list(), integer() | nil) ::
  {:ok, map()} | {:error, any()}

Update aliases of the collections See more on qdrant

query-parameters

Query parameters

  • timeout optional : Wait for operation commit timeout in seconds. If timeout is reached - request will return with service error.

request-body-schema

Request body schema

  • actions required: List of actions to perform. Create_alias or delete_alias or rename_alias.

example

Example

iex> Qdrant.update_aliases(%{
...>   actions: [
...>     %{create_alias: %{alias: "alias_name", collection: "collection_name"}},
...>     %{delete_alias: %{alias: "alias_name"}},
...>     %{rename_alias: %{alias: "alias_name", new_alias: "new_alias_name"}}
...>   ]
...> })
{:ok, %{"result" => true, "status" => "ok", "time" => 0}}
Link to this function

update_collection(collection_name, body, timeout \\ nil)

View Source
@spec update_collection(String.t(), update_collection_body(), integer() | nil) ::
  {:ok, map()} | {:error, any()}

Update collection parameters See more on qdrant

path-parameters

Path parameters

  • collection_name required : Name of the collection to update

query-parameters

Query parameters

  • timeout optional : Wait for operation commit timeout in seconds. If timeout is reached - request will return with service error.

request-body-schema

Request body schema

  • optimizers_config optional: Custom params for Optimizers. If none - values from service configuration file are used. This operation is blocking, it will only proceed ones all current optimizations are complete

  • params optional: Collection base params. If none - values from service configuration file are used.

Link to this function

update_collection_cluster(collection_name, body, timeout \\ nil)

View Source
@spec update_collection_cluster(String.t(), cluster_update_body(), integer() | nil) ::
  {:ok, map()} | {:error, any()}

Update collection cluster setup See more on qdrant

path-parameters

Path parameters

  • collection_name required : Name of the collection on which to to apply the cluster update operation

query-parameters

Query parameters

  • timeout optional : Wait for operation commit timeout in seconds. If timeout is reached - request will return with service error.

request-body-schema

Request body schema

  • move_shard or replicate_shard or abort_transfer or drop_replica required : List of actions to perform.

example

Example

iex> Qdrant.update_collection_cluster("collection_name", %{
...>   move_shard: %{
...>     shard_id: 1,
...>     to_peer_id: 42,
...>     from_peer_id: 69
...>   }
...> })
{:ok, %{"status" => "ok", "time" => 0, "result" => %{"operation_id" => 42, status: "acknowledged"} }}}}

iex> Qdrant.update_collection_cluster("collection_name", %{
...>   drop_replica: %{
...>     shard_id: 1,
...>     peer_id: 42
...>   }
...> })
{:ok, %{"status" => "ok", "time" => 0, "result" => %{"operation_id" => 42, status: "acknowledged"} }}}}