0
子字段我已經能夠得到正確的ElasticSearch命令插入和基於我下面原始請求尋找我的記錄:ElasticSearch NEST手動映射需要分析
Original ElasticSearch trying to be converted to NEST
PUT /sample
{
"settings": {
"index.number_of_shards": 5,
"index.number_of_replicas": 0,
"analysis": {
"filter": {
"nGram_filter": {
"type": "nGram",
"min_gram": 2,
"max_gram": 20,
"token_chars": [
"letter",
"digit"
]
},
"edgenGram_filter": {
"type": "edgeNGram",
"min_gram": 2,
"max_gram": 20
}
},
"analyzer": {
"ngram_index_analyzer": {
"type": "custom",
"tokenizer": "keyword",
"filter": [
"lowercase",
"nGram_filter"
]
},
"edge_ngram_index_analyzer": {
"type": "custom",
"tokenizer": "keyword",
"filter": [
"lowercase",
"edgenGram_filter"
]
}
}
}
},
"mappings": {
"test": {
"properties": {
"name": {
"type": "string",
"fields": {
"prefixes": {
"type": "string",
"analyzer": "edge_ngram_index_analyzer",
"search_analyzer": "standard"
},
"substrings": {
"type": "string",
"analyzer": "ngram_index_analyzer",
"search_analyzer": "standard"
}
}
}
}
}
}
}
然而,我我現在有嘗試使用NEST命令轉換此示例的問題。這是我迄今爲止所做的,編譯並將創建索引,但前綴和子字段的子字段不存在。
Client.CreateIndex("sample", i => i
.Settings(s => s
.NumberOfShards(10)
.NumberOfReplicas(0)
.Analysis(a => a
.TokenFilters(tf => tf
.NGram("nGram_filter", td => td
.MinGram(2)
.MaxGram(20)
)
.EdgeNGram("edgeNGram", td => td
.MinGram(2)
.MaxGram(20)
)
)
.Analyzers(anz => anz
.Custom("ngram_index_analyzer", cc => cc
.Tokenizer("keyword")
.Filters("lowercase", "nGram_filter")
)
.Custom("edge_ngram_index_analyzer", cc => cc
.Tokenizer("keyword")
.Filters("lowercase", "edgenGram_filter")
)
)
)
)
.Mappings(m => m
.Map<test>(map => map
.Properties(ps => ps
.Text(t => t
.Name(n => n.name)
.Fields(f => f
.Text(tt => tt
.Name("prefixes")
.Analyzer("edge_ngram_index_analyzer")
.SearchAnalyzer("standard")
)
.Text(tt => tt
.Name("substrings")
.Analyzer("ngram_index_analyzer")
.SearchAnalyzer("standard")
)
)
)
)
)
)
);
這很棒!我沒有意識到EdgeNGram過濾器的名稱是錯誤的。現在它按預期工作。謝謝 –