Creating an index Nest

后端 未结 5 1233
傲寒
傲寒 2020-12-19 03:01

How would I recreate the following index using Elasticsearch Nest API?

Here is the json for the index including the mapping:

{
    \"settings\": {
           


        
5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-19 03:30

    In case anyone has migrated to NEST 2.4 and has the same question - you would need to define your custom filters and analyzers in the index settings like this:

            elasticClient.CreateIndex(_indexName, i => i
                .Settings(s => s
                    .Analysis(a => a
                        .TokenFilters(tf => tf
                            .EdgeNGram("edge_ngrams", e => e
                                .MinGram(1)
                                .MaxGram(50)
                                .Side(EdgeNGramSide.Front)))
                            .Analyzers(analyzer => analyzer
                                .Custom("partial_text", ca => ca
                                    .Filters(new string[] { "lowercase", "edge_ngrams" })
                                    .Tokenizer("standard"))
                                .Custom("full_text", ca => ca
                                    .Filters(new string[] { "standard", "lowercase" } )
                                    .Tokenizer("standard"))))));
    

提交回复
热议问题