Set index.query.default_field using NEST Client c#

时光总嘲笑我的痴心妄想 提交于 2019-12-12 03:44:42

问题


I need to set index.query.default_field while creating index.How can I do it using Nest client c#. Added my create index code.Where do I set default_field property?

 var fullNameFilters = new List<string> { "lowercase", "snowball" };
    client.CreateIndex("mydocs", c => c
          .Settings(st => st
                    .Analysis(anl => anl
                    .Analyzers(h => h
                        .Custom("full", ff => ff
                             .Filters(fullNameFilters)
                             .Tokenizer("standard"))
                        )
                        .TokenFilters(ba => ba
                            .Snowball("snowball", sn => sn
                                .Language(SnowballLanguage.English)))                    
                        ))
                     .Mappings(mp => mp
                     .Map<IndexDocument>(ms => ms
                     .AutoMap()
                     .Properties(ps => ps
                         .Nested<Attachment>(n => n
                             .Name(sc => sc.File)
                         .AutoMap()
                         ))
                    .Properties(at => at
                    .Attachment(a => a.Name(o => o.File)
                    .FileField(fl=>fl.Analyzer("full"))
                    .TitleField(t => t.Name(x => x.Title)
                    .Analyzer("full")
                    .TermVector(TermVectorOption.WithPositionsOffsets)
                    )))

                    ))                        
                    );

回答1:


You can use Settings method when creating index:

var createIndexResponse =
    client.CreateIndex(indexName, c => c
        .Settings(s => s.Setting("index.query.default_field", "field"))
        .Mappings(m => m
            .Map<Document>(mp => mp.AutoMap())));

Hope it helps.



来源:https://stackoverflow.com/questions/37967551/set-index-query-default-field-using-nest-client-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!