NEST与JSON语法对照 一 match与multi_match

JSON

{ 
  "query": {  
    "bool": {    
      "must": [   
        {        
          "multi_match": {
            "query": "一二三",       
            "fields": ["title","summary"]
            } 
            }, 
            {"match": {"userId": {"query": "123456"}}    
        }  
      ]
    }
  }
}

  C#

search.Query(
                        q => q.Bool(
                            b => b.Must(
                                m => m.MultiMatch(
                                    l => l.Query("一二三").OnFields(new[] {"title","summary"})
                                   ),
                                   m => m.Match(t => t.OnField(o => o.UserId).Query("123456"))
                                )
                            )
                        )

当然如果是Json 

{"match": {"userId": {"query": "123456"}} <br>也可以表述为

  

{"match": {"userId":"123456"}<br><br>其中OnField/OnFields可以使用lamdba 表达式来选择属性,也可以使用字符串<br><br>

 

posted on 2016-01-12 14:14  水行者  阅读(594)  评论(0编辑  收藏  举报

导航