zoukankan      html  css  js  c++  java
  • NEST search查询

            /// <summary>
            /// GET /megacorp/employee/_search
            /// </summary>
            /// <returns></returns>
            public ISearchResponse<employee> QueryDoc()
            {
                var response = client.Search<employee>();
                Console.WriteLine(JsonConvert.SerializeObject(response));
                return response;
            }
    
            /// <summary>
            /// GET /megacorp/employee/_search
            /// queryMatch
            /// </summary>
            /// <returns></returns>
            public ISearchResponse<employee> QueryMatchDoc()
            {
                var response = client.Search<employee>(s =>
                    s.Query(
                        q => q.Match(m => m.Field(f => f.last_name).Query("明狮"))
                        ));
                Console.WriteLine(JsonConvert.SerializeObject(response));
                return response;
            }
    
            /// <summary>
            /// GET /megacorp/employee/_search
            /// queryBool
            /// </summary>
            /// <returns></returns>
            public ISearchResponse<employee> QueryBoolDoc()
            {
                var response = client.Search<employee>(s =>
                    s.Query(
                        q => q.Bool(
                            b => b.Must(m => m.Match(mm => mm.Field(f => f.last_name).Query("小明")))
                                .Filter(f => f.Range(r => r.Field(ff => ff.age).GreaterThan(20)))
                            )));
                Console.WriteLine(JsonConvert.SerializeObject(response));
                return response;
            }
    
            /// <summary>
            /// GET /megacorp/employee/_search
            /// queryMatchPhrase
            /// </summary>
            /// <returns></returns>
            public ISearchResponse<employee> QueryMatchParseDoc()
            {
                var response = client.Search<employee>(s =>
                    s.Query(
                        q => q.MatchPhrase(m => m.Field(f => f.last_name).Query("小明"))));
                Console.WriteLine(JsonConvert.SerializeObject(response));
                return response;
            }
    
            /// <summary>
            /// GET /megacorp/employee/_search
            /// queryHighlight
            /// </summary>
            /// <returns></returns>
            public ISearchResponse<employee> QueryHighLightDoc()
            {
                var response = client.Search<employee>(s =>
                    s.Query(
                        q => q.MatchPhrase(m => m.Field(f => f.last_name).Query("狮")))
                        .Highlight(h => h.Fields(ff => ff.Field(fff => fff.last_name))));
                Console.WriteLine(JsonConvert.SerializeObject(response));
                return response;
            }
    
            /// <summary>
            /// GET /megacorp/employee/_search
            /// queryAggregations
            /// </summary>
            /// <returns></returns>
            public ISearchResponse<employee> QueryAggsDoc()
            {
                var response = client.Search<employee>(s => s.Aggregations(a => a.Terms("ages", t => t.Field(f => f.age))));
                Console.WriteLine(JsonConvert.SerializeObject(response));
                return response;
            }
    

      

  • 相关阅读:
    win8 vs2010 openni2 配置
    写一个程序,分析一个文本文件(英文文章)中各个词出现的频率,并且把频率最高的十个词打印出来。
    电梯调度
    new 一个button 然后dispose,最后这个button是null吗???
    org.apache.hadoop.security.AccessControlException
    算法导论第二章、插入排序
    算法导论第六章、堆排序
    算法导论第八章、计数排序
    观后感
    第二次随笔
  • 原文地址:https://www.cnblogs.com/chenyishi/p/11542124.html
Copyright © 2011-2022 走看看