gpt4 book ai didi

elasticsearch - copy_to elasticsearch 6分析仪

转载 作者:行者123 更新时间:2023-12-03 01:39:46 26 4
gpt4 key购买 nike

我正在为dot.net使用Elasticsearch 6 Nest
我使用_all字段来搜索所有索引,但是现在不推荐使用,所以我需要一个新的解决方案

我发现copy_to选项足够好。

我的问题是:出于我的项目原因,我曾经在_all字段中定义应使用的分析器(ngram)和应使用的搜索分析器(空格)。

现在,由于在映射中未声明copy_to字段,因此我无法对其进行定义,因此不胜感激。

var res = client1.CreateIndex(INDEX_NAME, desc => desc
.InitializeUsing(indexState)
.Settings(x => x
.Analysis(g => g
.Tokenizers(t => t
.NGram("ngram_tokenizer", y => y
.MinGram(3)
.MaxGram(7)
.TokenChars(
TokenChar.Letter,
TokenChar.Digit,
TokenChar.Punctuation,
TokenChar.Symbol
)))
.Analyzers(o => o
.Custom("ngram_analyzer", w => w.Tokenizer("ngram_tokenizer").Filters("lowercase"))
.Whitespace("whitespace_analyzer")
.Standard("standard_analyzer", e => e.MaxTokenLength(1111)))))
.Mappings(ms => ms
.Map<SampleClass>(m => m
.AutoMap() //Still auto map exists if there are attributes on the class definition
.Properties(ps => ps //Override auto map
.Text(s => s
.Name(n => n.SampleString)
.CopyTo(am=>am.Field("searchallfield")))
.Number(s => s
.Name(n => n.SampleInteger))
.Date(s => s
.Name(n => n.SampleDateTime)
.Format("MM-DD-YY"))
))));

最佳答案

显然,您可以在映射中定义copy_to字段

                    .Map<SampleClass>(m => m
.AutoMap() //Still auto map exists if there are attributes on the class definition
.Properties(ps => ps //Override auto map
.Text(yy=>yy
.Name("searchallfield")
.SearchAnalyzer("whitespace_analyzer")
.Analyzer("ngram_analyzer"))
.Text(s => s
.Name(n => n.SampleString)
.CopyTo(am=>am.Field("searchallfield")))
.Number(s => s
.Name(n => n.SampleInteger))
.Date(s => s
.Name(n => n.SampleDateTime))

关于elasticsearch - copy_to elasticsearch 6分析仪,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48733073/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com