首页 > 其他 > 详细

NEST 字符串sort

时间:2019-09-21 11:29:53      阅读:103      评论:0      收藏:0      [点我收藏+]

text字符串sort会先分词。可先建立filed字段。并设置为keyword

mapping

        public void Mapping()
        {
            var response = client.IndexExists("employee");
            if (!response.Exists)
            {
                client.CreateIndex("employee");
            }
            client.Map<employee>(m => m.Properties(p => p.Text(t => t.Name("last_name").Fielddata().Analyzer("english").Fields(f=>f.Keyword(k=>k.Name("raw"))))).AutoMap());
        }

  

sort

        public void Sort()
        {
           // client.Search<employee>(s => s.Query(q => q.Bool(b => b.Filter(f => f.Term(t => t.Field("last_name").Value("test01"))))).Pretty());
            client.Search<employee>(s =>
                s.Query(q =>
                    q.ConstantScore(c =>
                        c.Filter(f =>
                            f.Term(t =>
                                t.Field("age").Value("26")
                                ))))
                    .Sort(so => 
                    so.Descending("last_name")
                     )
                    .Pretty());

        }

技术分享图片

 

NEST 字符串sort

原文:https://www.cnblogs.com/chenyishi/p/11561482.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!