2

We are trying to pass aggregations through NEST in Raw format:

{
"query": {
    "filtered": {
        "query": {
            "multi_match": {
                "query": "main",
                "type": "cross_fields",
                "fields": [
                    "field1",
                    "field2^5",
                ],
                "operator": "and"
            }
        }
    }
},
"aggregations": {
    "multiselectTerms": {
        "terms": {
            "field": "field1.raw",
            "order": {
                "_count": "desc"
            }
        }
    }
}

}

But when we pass the above JSON in NEST we are not getting the result. Can someone please provide some input how we can pass aggregations in NEST.

var uri = new Uri(ConfigurationManager.AppSettings["ELASTICSEARCH_SERVER"]);
        var settings = new ConnectionSettings(uri, defaultIndex: ConfigurationManager.AppSettings["indexName"]);
        settings.EnableTrace(true);
        var client = new ElasticClient(settings);
        var resp=client.Search<dynamic>(q =>
            q.Type("mappingType").QueryRaw(reqObj["query"].ToString()).From(Convert.ToInt32(((JValue)reqObj["from"]))).Size(Convert.ToInt32(((JValue)reqObj["size"])))
            );

In response we are getting no data for aggregations & hits.

code_blue
  • 523
  • 2
  • 9
  • 19
  • Please elaborate what do you mean by "we are not getting the result". Also please post error log. – Sufian Apr 29 '15 at 14:25
  • 1
    use Fiddler to see what data is getting passed to ES as well as what is returned. As well, you should be able to write this same query in the fluent syntax which would probably make this a little easier. – jhilden Apr 29 '15 at 14:29

0 Answers0