• 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;
            }
    

      

  • 相关阅读:
    Redis 配置为 Service 系统服务
    java.lang.IllegalStateException: The platform metadata area could not be written
    SpringCloud Gateway做熔断降级+限流
    Mac mysql修改my.cnf不起作用排查
    MailHealthIndicator javax.mail.MessagingException: Could not connect to SMTP host: smtp.qiye.aliyun.com, port: 25, response: -1
    Spring Cloud Gateway跨域配置
    一、Rancher单机搭建
    SpringCloud快速搭建微服务
    在Mac下为GUI程序设定环境变量
    Spring cache 使用说明
  • 原文地址:https://www.cnblogs.com/chenyishi/p/11542124.html
Copyright © 2020-2023  润新知