NEST 字符串sort

匿名 (未验证) 提交于 2019-12-03 00:10:02

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());          }

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