Skip to content

Commit

Permalink
Merge pull request #978 from milvus-io/update-ref
Browse files Browse the repository at this point in the history
update docs
  • Loading branch information
liyun95 authored Dec 23, 2024
2 parents 9ef3e56 + a527132 commit 940c997
Show file tree
Hide file tree
Showing 16 changed files with 345 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ CollectionSchema.addField(AddFieldReq.builder()
.maxCapacity(Integer maxCapacity)
.isNullable(Boolean isNullable)
.defaultValue(DataType dataType)
.enableAnalyzer(Boolean enableAnalyzer)
.enableMatch(Boolean enableMatch)
.analyzerParams(Map<String, Object>, analyzerParams)

.build()
)
Expand Down Expand Up @@ -110,6 +113,45 @@ CollectionSchema.addField(AddFieldReq.builder()

Sets a default value for a specific field in a collection schema when creating it. This is particularly useful when you want certain fields to have an initial value even if no value is explicitly provided during data insertion.

- `enableAnalyzer(Boolean enableAnalyzer)`

Whether to enable text analysis for the specified `VARCHAR` field. When set to `true`, it instructs Milvus to use a text analyzer, which tokenizes and filters the text content of the field.

- `enableMatch(Boolean enableMatch)`

Whether to enable keyword matching for the specified `VARCHAR` field. When set to `true`, Milvus creates an inverted index for the field, allowing for quick and efficient keyword lookups. `enableMatch` works in conjunction with `enableAnalyzer` to provide structured term-based text search, with `enableAnalyzer` handling tokenization and `enableMatch` handling the search operations on these tokens.

- `analyzerParams(Map<String, Object>, analyzerParams)`

Configures the analyzer for text processing, specifically for `DataType.VarChar` fields. This parameter configures tokenizer and filter settings, particularly for text fields used in [keyword matching](https://milvus.io/docs/keyword-match.md) or [full text search](https://milvus.io/docs/full-text-search.md). Depending on the type of analyzer, it can be configured in either of the following methods:

- Built-in analyzer

```java
Map<String, Object> analyzerParams = new HashMap<>();
analyzerParams.put("type", "english");
```

- `type` (*String*) -

Pre-configured analyzer type built into Milvus, which can be used out-of-the-box by specifying its name. Possible values: `standard`, `english`, `chinese`. For more information, refer to [Standard Analyzer](https://milvus.io/docs/standard-analyzer.md), [English Analyzer](https://milvus.io/docs/english-analyzer.md), and [Chinese Analyzer](https://milvus.io/docs/chinese-analyzer.md).

- Custom analyzer

```java
Map<String, Object> analyzerParams = new HashMap<>();
analyzerParams.put("tokenizer", "standard");
analyzerParams.put("filter", Collections.singletonList("lowercase"));
```

- `tokenizer` (*String*) -

Defines the tokenizer type. Possible values: `standard` (default), `whitespace`, `jieba`. For more information, refer to [Standard Tokenizer](https://milvus.io/docs/standard-tokenizer.md), [Whitespace Tokenizer](https://milvus.io/docs/whitespace-tokenizer.md), and [Jieba Tokenizer](https://milvus.io/docs/jieba-tokenizer.md).

- `filter` (*List\<String>*) -

Lists filters to refine tokens produced by the tokenizer, with options for built-in filters and custom filters. For more information, refer to [Alphanumonly Filter](https://milvus.io/docs/alphanumonly-filer.md) and others.

**RETURNS:**

*void*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# addFunction()

This operation adds a function to convert raw data into vector representations.

```java
public CollectionSchema addFunction(Function function)
```

## Request Syntax

```java
addFunction(Function.builder()
.functionType(FunctionType functionType)
.name(String name)
.inputFieldNames(List<String> inputFieldNames)
.outputFieldNames(List<String> outputFieldNames)
.description(String description)
.build());
```

**BUILDER METHODS:**

- `functionType(FunctionType functionType)`

The type of function for processing raw data. Possible values:

- `FunctionType.BM25`: Uses the BM25 algorithm for generating sparse embeddings from a `VARCHAR` field.

- `name(String name)`

The name of the function. This identifier is used to reference the function within queries and collections.

- `inputFieldNames(List<String> inputFieldNames)`

The name of the field containing the raw data that requires conversion to vector representation. For functions using `FunctionType.BM25`, this parameter accepts only one field name.

- `outputFieldNames(List<String> outputFieldNames)`

The name of the field where the generated embeddings will be stored. This should correspond to a vector field defined in the collection schema. For functions using `FunctionType.BM25`, this parameter accepts only one field name.

- `description(String description)`

A brief description of the function’s purpose. This can be useful for documentation or clarity in larger projects and defaults to an empty string.

**RETURN TYPE:**

*Function*

**RETURNS:**

A `Function` object

**EXCEPTIONS:**

- **MilvusClientExceptions**

This exception will be raised when any error occurs during this operation.

## Example

```java
import io.milvus.common.clientenum.FunctionType;
import io.milvus.v2.service.collection.request.CreateCollectionReq.Function;

import java.util.*;

schema.addFunction(Function.builder()
.functionType(FunctionType.BM25)
.name("text_bm25_emb")
.inputFieldNames(Collections.singletonList("text"))
.outputFieldNames(Collections.singletonList("vector"))
.build());
```
69 changes: 69 additions & 0 deletions API_Reference/milvus-sdk-java/v2.5.x/v2/Collections/Function.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Function

A `Function` instance for generating vector embeddings from user-provided raw data in Milvus.

```java
io.milvus.v2.service.collection.request.CreateCollectionReq.Function
```

## Constructor

This constructor initializes a new `Function` instance designed to transform user's raw data into vector embeddings. This is achieved through an automated process that simplifies similarity search operations.

```java
CreateCollectionReq.Function.builder()
.name(String name)
.description(String description)
.functionType(FunctionType functionType)
.inputFieldNames(List<String> inputFieldNames)
.outputFieldNames(List<String> outputFieldNames)
```

**BUILDER METHODS:**

- `name(String name)`

The name of the function. This identifier is used to reference the function within queries and collections.

- `description(String description)`

A brief description of the function's purpose. This can be useful for documentation or clarity in larger projects and defaults to an empty string.

- `functionType(FunctionType functionType)`

The type of function for processing raw data. Possible values:

- `FunctionType.BM25`: Uses the BM25 algorithm for generating sparse embeddings from a `VARCHAR` field.

- `inputFieldNames(List<String> inputFieldNames)`

The name of the field containing the raw data that requires conversion to vector representation. For functions using `FunctionType.BM25`, this parameter accepts only one field name.

- `outputFieldNames(List<String> outputFieldNames)`

The name of the field where the generated embeddings will be stored. This should correspond to a vector field defined in the collection schema. For functions using `FunctionType.BM25`, this parameter accepts only one field name.

**RETURN TYPE:**

*Function*

**RETURNS:**

A `Function` object that can be registered with a Milvus collection, facilitating automatic embedding generation during data insertion.

**EXCEPTIONS:**

- **MilvusClientExceptions**

This exception will be raised when any error occurs during this operation.

## Example

```java
CreateCollectionReq.Function.builder()
.functionType(FunctionType.BM25)
.name("text_bm25_emb")
.inputFieldNames(Collections.singletonList("text"))
.outputFieldNames(Collections.singletonList("vector"))
.build());
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# FunctionType

This is an enumeration that provides the following constants.

## Constants

- BM25

Sets the function type to **BM25**.

- Unknown

Sets the function type to **Unknown**.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ IndexParam.builder()

- `metricType(IndexParam.MetricType metricType)`

The distance metric to use for the index. Possible values are **L2**, **IP**, **COSINE**, **HAMMING**, and **JACCARD**.
The algorithm that is used to measure similarity between vectors. Possible values: `IP`, `L2`, `COSINE`, `HAMMING`, `JACCARD`, `BM25` (used only for full text search). For more information, refer to [Metric Types](https://milvus.io/docs/metric.md).

This is available only when the specified field is a vector field.

- `extraParams(Map<String, Object> extraParams)`

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Function

A `Function` instance for generating vector embeddings from user-provided raw text data in Milvus.
A `Function` instance for generating vector embeddings from user-provided raw data in Milvus.

```python
class pymilvus.Function
Expand All @@ -27,7 +27,7 @@ Function(

**[REQUIRED]**

The name of the function. This identifier is used to reference the function within queries and collections.
The name of the function. This identifier is used to reference the function within queries and collections.

- `function_type` (*FunctionType*) -

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ IndexParams.add_index(

- **metric_type** (*str*) -

The algorithm that is used to measure similarity between vectors. Possible values: `IP`, `L2`, `COSINE`, `HAMMING`, `JACCARD`, `BM25`. For more information, refer to [Metric Types](https://milvus.io/docs/metric.md).
The algorithm that is used to measure similarity between vectors. Possible values: `IP`, `L2`, `COSINE`, `HAMMING`, `JACCARD`, `BM25` (used only for full text search). For more information, refer to [Metric Types](https://milvus.io/docs/metric.md).

This is available only when the specified field is a vector field.
This is available only when the specified field is a vector field.

- **params** (*dict*) -

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ import RestSpecs from '@site/src/components/RestSpecs';

<RestSpecs specs={specs} endpoint={endpoint} method={method} target="milvus" lang="en-US" />

export const specs = {"summary":"List Collections","deprecated":false,"description":"This operation lists all collection names.","x-i18n":{"zh-CN":{"summary":"查看 Collection 列表","description":"列出所有 Collection 名称。"}},"tags":["Collection Operations (V2)"],"parameters":[{"name":"Authorization","in":"header","description":"The authentication token should be <include target=\"zilliz\">an API key with appropriate privileges or </include>a pair of colon-joined username and password, like `username:password`.","required":true,"example":"Bearer {{TOKEN}}","schema":{"type":"string"},"x-i18n":{"zh-CN":{"description":"认证令牌,应为<include target=\"zilliz\">具备适当权限的 API 密钥或</include>用冒号分隔的用户名和密码,如 `username:password`。"}}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"dbName":{"type":"string","description":"The name of an existing database.","x-i18n":{"zh-CN":{"description":"现有数据库名称。"}},"x-include-target":["milvus"]}}},"examples":{"1":{"summary":"milvus","x-include-target":["milvus"],"value":{"dbName":"_default"}},"2":{"summary":"zilliz","x-include-target":["zilliz"],"value":{}}}}}},"responses":{"200":{"description":"This operation lists all collections in the database used in the current connection.","x-i18n":{"zh-CN":{"description":"该操作列出当前连接中使用的数据库中的所有 Collection。"}},"content":{"application/json":{"schema":{"oneOf":[{"x-tab-label":"success","type":"object","properties":{"code":{"description":"Response code.","x-i18n":{"zh-CN":{"description":"响应码。"}},"type":"integer"},"data":{"type":"array","items":{"type":"string","description":"A collection name.","x-i18n":{"zh-CN":{"description":"Collection 名称。"}}},"description":"Response payload which is a list of collection names.","x-i18n":{"zh-CN":{"description":"响应载荷,一个 Collection 名称列表。"}}}}},{"x-tab-label":"failure","description":"Returns an error message.","x-i18n":{"zh-CN":{"description":"返回错误消息。"}},"x-i18n-langs":["zh-CN"],"type":"object","properties":{"code":{"type":"integer","description":"Response code.","x-i18n":{"zh-CN":{"description":"响应码。"}}},"message":{"type":"string","description":"Error message.","x-i18n":{"zh-CN":{"description":"错误描述。"}}}}}]},"examples":{"1":{"summary":"success","x-target-response":"OPTION 1","value":{"code":0,"data":["quick_setup_new","customized_setup_1","customized_setup_2"]}},"2":{"summary":"failure","x-target-response":"OPTION 2","value":{"code":0,"message":"The token is illegal."}}}}}}},"security":[]}
export const specs = {"summary":"List Collections","deprecated":false,"description":"This operation lists all collection names.","x-i18n":{"zh-CN":{"summary":"查看 Collection 列表","description":"列出所有 Collection 名称。"}},"tags":["Collection Operations (V2)"],"parameters":[{"name":"Authorization","in":"header","description":"The authentication token should be <include target=\"zilliz\">an API key with appropriate privileges or </include>a pair of colon-joined username and password, like `username:password`.","required":true,"example":"Bearer {{TOKEN}}","schema":{"type":"string"},"x-i18n":{"zh-CN":{"description":"认证令牌,应为<include target=\"zilliz\">具备适当权限的 API 密钥或</include>用冒号分隔的用户名和密码,如 `username:password`。"}}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"dbName":{"type":"string","description":"The name of an existing database.","x-i18n":{"zh-CN":{"description":"现有数据库名称。"}}}}},"example":{"dbName":"_default"}}}},"responses":{"200":{"description":"This operation lists all collections in the database used in the current connection.","x-i18n":{"zh-CN":{"description":"该操作列出当前连接中使用的数据库中的所有 Collection。"}},"content":{"application/json":{"schema":{"oneOf":[{"x-tab-label":"success","type":"object","properties":{"code":{"description":"Response code.","x-i18n":{"zh-CN":{"description":"响应码。"}},"type":"integer"},"data":{"type":"array","items":{"type":"string","description":"A collection name.","x-i18n":{"zh-CN":{"description":"Collection 名称。"}}},"description":"Response payload which is a list of collection names.","x-i18n":{"zh-CN":{"description":"响应载荷,一个 Collection 名称列表。"}}}}},{"x-tab-label":"failure","description":"Returns an error message.","x-i18n":{"zh-CN":{"description":"返回错误消息。"}},"x-i18n-langs":["zh-CN"],"type":"object","properties":{"code":{"type":"integer","description":"Response code.","x-i18n":{"zh-CN":{"description":"响应码。"}}},"message":{"type":"string","description":"Error message.","x-i18n":{"zh-CN":{"description":"错误描述。"}}}}}]},"examples":{"1":{"summary":"success","x-target-response":"OPTION 1","value":{"code":0,"data":["quick_setup_new","customized_setup_1","customized_setup_2"]}},"2":{"summary":"failure","x-target-response":"OPTION 2","value":{"code":0,"message":"The token is illegal."}}}}}}},"security":[]}
export const endpoint = "/v2/vectordb/collections/list"
export const method = "post"
20 changes: 20 additions & 0 deletions API_Reference_MDX/milvus-restful/v2.5.x/v2/Database (v2)/alter.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
displayed_sidebar: restfulSidebar
sidebar_positition: 10
slug: /restful/alter
title: "Alter | RESTful"
description: "This operation modifies a new database. | RESTful"
hide_table_of_contents: true
sidebar_label: "Alter"
sidebar_custom_props: { badges: ['post']}
---

# Alter

import RestSpecs from '@site/src/components/RestSpecs';

<RestSpecs specs={specs} endpoint={endpoint} method={method} target="milvus" lang="en-US" />

export const specs = {"summary":"Alter","deprecated":false,"description":"This operation modifies a new database.","x-i18n":{"zh-CN":{"summary":"修改数据库","description":"此操作用于修改指定数据库。"}},"tags":["Database Operations (V2)"],"x-include-target":["milvus"],"parameters":[{"name":"Authorization","in":"header","description":"The authentication token should be <include target=\"zilliz\">an API key with appropriate privileges or </include>a pair of colon-joined username and password, like `username:password`.","required":true,"example":"Bearer {{TOKEN}}","schema":{"type":"string"},"x-i18n":{"zh-CN":{"description":"认证令牌,应为<include target=\"zilliz\">具备适当权限的 API 密钥或</include>用冒号分隔的用户名和密码,如 `username:password`。"}}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"dbName":{"type":"string","description":"The name of the database to modify.","x-i18n":{"zh-CN":{"description":"待修改数据库名称。"}}},"properties":{"type":"object","description":"Database properties to modify. For example, you can reset the `mmap.enabled` property to `false` to disable the mmap feature for the collections in the database.","x-i18n":{"zh-CN":{"description":"待修改的数据库属性。例如,可以重新设置 `mmap.enabled` 属性为 `false` 以禁用数据库中 Collection 的 mmap 特性。"}}}},"required":["dbName"]},"example":{"dbName":"test","properties":{"mmap.enabled":true}}}}},"responses":{"200":{"description":"Returns an empty object.","x-i18n":{"zh-CN":{"description":"返回空对象。"}},"content":{"application/json":{"schema":{"oneOf":[{"x-tab-label":"success","type":"object","properties":{"code":{"type":"integer","description":"Response code.","x-i18n":{"zh-CN":{"description":"响应码。"}}},"data":{"type":"object","description":"Response payload which is an empty object.","x-i18n":{"zh-CN":{"description":"响应载荷,为空对象。"}},"properties":{}}}},{"x-tab-label":"failure","description":"Returns an error message.","x-i18n":{"zh-CN":{"description":"返回错误消息。"}},"x-i18n-langs":["zh-CN"],"type":"object","properties":{"code":{"type":"integer","description":"Response code.","x-i18n":{"zh-CN":{"description":"响应码。"}}},"message":{"type":"string","description":"Error message.","x-i18n":{"zh-CN":{"description":"错误描述。"}}}}}]},"examples":{"1":{"summary":"success","x-target-response":"OPTION 1","value":{"code":0,"data":{}}},"2":{"summary":"failure","x-target-response":"OPTION 2","value":{"code":0,"message":"The token is illegal."}}}}}}}}
export const endpoint = "/v2/vectordb/databases/alter"
export const method = "post"
Loading

0 comments on commit 940c997

Please sign in to comment.