Facing some problem while trying to create lambda

2019-08-24 03:24发布

问题:

As of now i have Elastic query with json format, now i am trying to convert this query with Nest extension for Asp.Net c# in lambda expression. Facing this problem, any body can help to create the Lambda expression with help of json query.

I have tried, but it's list type inside the query, so while i am trying giving error might be my lambda expression is not correct.

{
  "query": {
    "bool": {      
      "must": [        
        {
          "bool": {
            "should": [
              {
                "bool": {
                  "must": [
                    {
                      "term": {
                        "variant": "vxi"
                      }
                    },
                    {
                      "term": {
                        "model": "a star"
                      }
                    }
                  ]
                }
              },
              {
                "bool": {
                  "must": {
                    "terms": {
                      "model": [
                        "eeco"
                      ]
                    }
                  }
                }
              }
            ]
          }
        }
      ]
    }
  }
}

I have tried with this lambda expression, but while i am debugging then query is not creating as like json below, so need your help.

            var response = _esclient.EsClient().Search<MyClassname>(a => a
                            .Index
                            .Type
                            .Size
                            .From
                            .Query(q => q.Bool(b => b.Must(m => m.Terms(p => p.Field(ab => ab.model).Terms(searchAjaxRequest.modeltype)),
                                                               m => m.Terms(p => p.Field(ab => ab.variant).Terms(searchAjaxRequest.varientType)),

                                                           )    )))

Just want a Lambda expression in NEST ext. in c# or any tool market which i can use to create the lambda expression with help of json.