how to add a full phrase tokenizer in Nest for Elasticsearch?

 ̄綄美尐妖づ 提交于 2019-12-01 06:23:50

Use the multi field type in your mapping. Doing so will allow you to index the Genre field in two ways- analyzed (using the standard or lowercase analyzer) for conducting searches, and not_analyzed for faceting.

For more advanced mappings like this, the attribute based mapping in NEST won't cut it. You'll have to use the fluent API, for example:

client.CreatIndex("songs", c => c
.AddMapping<Song>(m => m
    .MapFromAttributes()
    .Properties(props => props
        .MultiField(mf => mf
            .Name(s => s.Genre)
            .Fields(f => f
                .String(s => s.Name(o => o.Genre).Analyzer("standard"))
                .String(s => s.Name(o => o.Genre.Suffix("raw")).Index(FieldIndexOption.not_analyzed)))))));

Hope this helps!

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