영숫자만

alphanumonly 필터는 영숫자가 아닌 문자가 포함된 토큰을 제거하고 영숫자 용어만 유지합니다. 이 필터는 특수 문자나 기호를 제외하고 기본 문자와 숫자만 관련된 텍스트를 처리하는 데 유용합니다.

구성

alphanumonly 필터는 Milvus에 내장되어 있습니다. 사용하려면 analyzer_params 내의 filter 섹션에 이름을 지정하기만 하면 됩니다.

analyzer_params = {
    "tokenizer": "standard",
    "filter": ["alphanumonly"],
}
Map<String, Object> analyzerParams = new HashMap<>();
analyzerParams.put("tokenizer", "standard");
analyzerParams.put("filter", Collections.singletonList("alphanumonly"));
const analyzer_params = {
    "tokenizer": "standard",
    "filter": ["alphanumonly"],
};
analyzerParams = map[string]any{"tokenizer": "standard", "filter": []any{"alphanumonly"}}
# restful
analyzerParams='{
  "tokenizer": "standard",
  "filter": [
    "alphanumonly"
  ]
}'

alphanumonly 필터는 토큰화 도구에서 생성된 용어에 대해 작동하므로 토큰화 도구와 함께 사용해야 합니다. Milvus에서 사용할 수 있는 토큰라이저 목록은 표준 토큰라이저와 그 자매 페이지를 참조하세요.

analyzer_params 을 정의한 후 컬렉션 스키마를 정의할 때 VARCHAR 필드에 적용할 수 있습니다. 이렇게 하면 Milvus가 지정된 분석기를 사용하여 해당 필드의 텍스트를 처리하여 효율적인 토큰화 및 필터링을 수행할 수 있습니다. 자세한 내용은 사용 예시를 참조하세요.

예제

분석기 구성을 컬렉션 스키마에 적용하기 전에 run_analyzer 메서드를 사용하여 그 동작을 확인하세요.

분석기 구성

analyzer_params = {
    "tokenizer": "standard",
    "filter": ["alphanumonly"],
}
Map<String, Object> analyzerParams = new HashMap<>();
analyzerParams.put("tokenizer", "standard");
analyzerParams.put("filter", Collections.singletonList("alphanumonly"));
// javascript
analyzerParams = map[string]any{"tokenizer": "standard", "filter": []any{"alphanumonly"}}
# restful

다음을 사용하여 확인 run_analyzerCompatible with Milvus 2.5.11+

from pymilvus import (
    MilvusClient,
)

client = MilvusClient(uri="http://localhost:19530")

# Sample text to analyze
sample_text = "Milvus 2.0 @ Scale! #AI #Vector_Databasé"

# Run the standard analyzer with the defined configuration
result = client.run_analyzer(sample_text, analyzer_params)
print("Standard analyzer output:", result)
import io.milvus.v2.client.ConnectConfig;
import io.milvus.v2.client.MilvusClientV2;
import io.milvus.v2.service.vector.request.RunAnalyzerReq;
import io.milvus.v2.service.vector.response.RunAnalyzerResp;

ConnectConfig config = ConnectConfig.builder()
        .uri("http://localhost:19530")
        .build();
MilvusClientV2 client = new MilvusClientV2(config);

List<String> texts = new ArrayList<>();
texts.add("Milvus 2.0 @ Scale! #AI #Vector_Databasé");

RunAnalyzerResp resp = client.runAnalyzer(RunAnalyzerReq.builder()
        .texts(texts)
        .analyzerParams(analyzerParams)
        .build());
List<RunAnalyzerResp.AnalyzerResult> results = resp.getResults();
// javascript
import (
    "context"
    "encoding/json"
    "fmt"

    "github.com/milvus-io/milvus/client/v2/milvusclient"
)

client, err := milvusclient.New(ctx, &milvusclient.ClientConfig{
    Address: "localhost:19530",
    APIKey:  "root:Milvus",
})
if err != nil {
    fmt.Println(err.Error())
    // handle error
}

bs, _ := json.Marshal(analyzerParams)
texts := []string{"Milvus 2.0 @ Scale! #AI #Vector_Databasé"}
option := milvusclient.NewRunAnalyzerOption(texts).
    WithAnalyzerParams(string(bs))

result, err := client.RunAnalyzer(ctx, option)
if err != nil {
    fmt.Println(err.Error())
    // handle error
}
# restful

예상 출력

['Milvus', '2', '0', 'Scale', 'AI', 'Vector']

Try Managed Milvus for Free

Zilliz Cloud is hassle-free, powered by Milvus and 10x faster.

Get Started
피드백

이 페이지가 도움이 되었나요?