표준 분석기
standard 분석기는 Milvus의 기본 분석기로, 분석기가 지정되지 않은 경우 텍스트 필드에 자동으로 적용됩니다. 이 분석기는 문법 기반 토큰화를 사용하므로 대부분의 언어에 효과적입니다.
standard 분석기는 단어 경계를 구분하는 데 구분자(공백, 구두점 등)를 사용하는 언어에 적합합니다. 그러나 중국어, 아랍어, 태국어, 일본어, 한국어와 같은 언어는 언어별 토큰화 또는 정규화가 필요합니다. 이러한 경우에는 다음과 같은 언어별 분석기를 사용하십시오. chinese, arabic, 또는 thai, 또는 다음과 같은 특수한 토큰화 기능을 갖춘 사용자 정의 분석기를 사용하십시오. lindera 와 icu와 같은 특수한 토큰화 기능을 갖춘 사용자 정의 분석기를 사용하십시오.
정의
standard 분석기는 다음으로 구성됩니다:
토큰화기: ‘
standard’ 토큰화기를 사용하여 문법 규칙에 따라 텍스트를 개별 단어 단위로 분할합니다. 자세한 내용은 표준 토큰화기를 참조하십시오.필터:
lowercase필터를 사용하여 모든 토큰을 소문자로 변환함으로써 대소문자를 구분하지 않는 검색을 가능하게 합니다. 자세한 내용은 소문자 변환을 참조하십시오.
standard 분석기의 기능은 다음 사용자 정의 분석기 구성과 동일합니다:
analyzer_params = {
"tokenizer": "standard",
"filter": ["lowercase"]
}
Map<String, Object> analyzerParams = new HashMap<>();
analyzerParams.put("tokenizer", "standard");
analyzerParams.put("filter", Collections.singletonList("lowercase"));
const analyzer_params = {
"tokenizer": "standard",
"filter": ["lowercase"]
};
analyzerParams := map[string]any{"tokenizer": "standard", "filter": []any{"lowercase"}}
# restful
analyzerParams='{
"tokenizer": "standard",
"filter": [
"lowercase"
]
}'
구성
standard 분석기를 필드에 적용하려면, analyzer_params 에서 ` type `을 ` standard `으로 설정하고, 필요에 따라 선택적 매개변수를 포함하면 됩니다.
analyzer_params = {
"type": "standard", # Specifies the standard analyzer type
}
Map<String, Object> analyzerParams = new HashMap<>();
analyzerParams.put("type", "standard");
const analyzer_params = {
"type": "standard", // Specifies the standard analyzer type
}
analyzerParams = map[string]any{"type": "standard"}
# restful
analyzerParams='{
"type": "standard"
}'
standard 분석기는 다음 선택적 매개변수를 지원합니다:
매개변수 |
설명 |
|---|---|
|
토큰화 과정에서 제외될 스톱워드 목록이 포함된 배열입니다. 기본값은 |
사용자 정의 스톱워드 구성 예시:
analyzer_params = {
"type": "standard", # Specifies the standard analyzer type
"stop_words", ["of"] # Optional: List of words to exclude from tokenization
}
Map<String, Object> analyzerParams = new HashMap<>();
analyzerParams.put("type", "standard");
analyzerParams.put("stop_words", Collections.singletonList("of"));
analyzer_params = {
"type": "standard", // Specifies the standard analyzer type
"stop_words", ["of"] // Optional: List of words to exclude from tokenization
}
analyzerParams = map[string]any{"type": "standard", "stop_words": []string{"of"}}
# restful
analyzer_params 를 정의한 후, 컬렉션 스키마를 정의할 때 ‘ VARCHAR ’ 필드에 이를 적용할 수 있습니다. 이를 통해 Milvus는 해당 필드의 텍스트를 지정된 분석기를 사용하여 처리함으로써 효율적인 토큰화 및 필터링을 수행할 수 있습니다. 자세한 내용은 사용 예시를 참조하십시오.
예시
분석기 구성을 컬렉션 스키마에 적용하기 전에, ` run_analyzer ` 메서드를 사용하여 동작을 확인해 보십시오.
분석기 구성
analyzer_params = {
"type": "standard", # Standard analyzer configuration
"stop_words": ["for"] # Optional: Custom stop words parameter
}
Map<String, Object> analyzerParams = new HashMap<>();
analyzerParams.put("type", "standard");
analyzerParams.put("stop_words", Collections.singletonList("for"));
// javascript
analyzerParams = map[string]any{"type": "standard", "stop_words": []string{"for"}}
# restful
analyzerParams='{
"type": "standard",
"stop_words": [
"of"
]
}'
다음 방법을 사용한 검증 run_analyzer
from pymilvus import (
MilvusClient,
)
client = MilvusClient(
uri="http://localhost:19530",
token="root:Milvus"
)
# Sample text to analyze
sample_text = "The Milvus vector database is built for scale!"
# 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")
.token("root:Milvus")
.build();
MilvusClientV2 client = new MilvusClientV2(config);
List<String> texts = new ArrayList<>();
texts.add("The Milvus vector database is built for scale!");
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{"The Milvus vector database is built for scale!"}
option := milvusclient.NewRunAnalyzerOption(texts).
WithAnalyzerParams(string(bs))
result, err := client.RunAnalyzer(ctx, option)
if err != nil {
fmt.Println(err.Error())
// handle error
}
# restful
예상 출력
Standard analyzer output: ['the', 'milvus', 'vector', 'database', 'is', 'built', 'scale']