0
자동 완성 기능을 만들려고 노력 중이지만 작동하는 것 같지만 사용자 정의 분석기가 때때로 이상한 결과를 반환한다는 것을 알게됩니다. 내가NEST 사용자 정의 분석기 NGram이 올바른 결과를 반환하지 않습니다.
127.0.0.1:9200/default-index/_analyze?text=dan&analyzer=auto-complete
그때 내가 그래서 위의 3 내 MinGram을 설정, 내가 설정을 확실히 잘못 실종되어
{
"tokens": [
{
"token": "d",
"start_offset": 0,
"end_offset": 3,
"type": "<ALPHANUM>",
"position": 0
},
{
"token": "da",
"start_offset": 0,
"end_offset": 3,
"type": "<ALPHANUM>",
"position": 0
},
{
"token": "a",
"start_offset": 0,
"end_offset": 3,
"type": "<ALPHANUM>",
"position": 0
},
{
"token": "an",
"start_offset": 0,
"end_offset": 3,
"type": "<ALPHANUM>",
"position": 0
},
{
"token": "n",
"start_offset": 0,
"end_offset": 3,
"type": "<ALPHANUM>",
"position": 0
}
]
}
를 얻을 호출하는 경우
var response = this.client.CreateIndex(
ElasticConfig.IndexName,
index => index
.Mappings(
ms => ms.Map<EmployeeDocument>(
m => m.Properties(
p => p
.Text(t => t.Name(n => n.EmpFirstName).Analyzer("auto-complete").Fields(ff => ff.Keyword(k => k.Name("keyword"))))
.Text(t => t.Name(n => n.pkEmpID).Analyzer("auto-complete").Fields(ff => ff.Keyword(k => k.Name("keyword"))))
.Text(t => t.Name(n => n.Description).Analyzer("auto-complete").Fields(ff => ff.Keyword(k => k.Name("keyword")))))))
.Settings(
f => f.Analysis(
analysis => analysis
.Tokenizers(
tokenizers =>
tokenizers
.EdgeNGram("ngram", t => t.MinGram(3).MaxGram(5)))
.Analyzers(
analyzers => analyzers.Custom(
"auto-complete",
a => a.Filters(new List<string> { "lowercase", "ngram" }).Tokenizer("standard"))))));
?