代码之家  ›  专栏  ›  技术社区  ›  Tim Miek

将Elasticsearch查询转换为。网络嵌套

  •  1
  • Tim Miek  · 技术社区  · 8 年前

    如何将elasticsearch匹配查询写入C。净巢。

     GET /disney2/character/_search
         {
         "query": {
         "match": {
         "name.phonetic": {
         "query": "Jahnnie Smeeth",
        "operator": "and"
         }
         }
         }
         } 
    
    1 回复  |  直到 8 年前
        1
  •  0
  •   Tim Miek    8 年前

    使用目标初始值设定项语法:

            ConnectionSettings _clientSettings = new ConnectionSettings(new Uri("http://localhost:9200/disney2"));
            var client = new ElasticClient(_clientSettings);
            var query = new SearchRequest<disney>(); // You're going to want to replace <object> with a model corresponding to your type, or specify the type via string
            var matcher = new MatchQuery();
            matcher.Field = "name.phonetic";
            matcher.Query = "Jahnnie Smith";
            matcher.Operator = Operator.And;
            query.Query = matcher;
    
            //var res = elasticClient.Search<disney>(query);
            var res = client.Search<disney>(query);