从NEST C#嵌套聚合中获取Elasticsearch结果

时间:2017-06-30 11:24:52

标签: c# elasticsearch nest

我有这个Elasticsearch NEST查询:

var res = elastic.Search<SegmentRecord>(s => s.Index(esIndex).Aggregations(a => a.Terms("agg", x => x.Field(o => o.InstrumentName).Aggregations(a1 => a1.Terms("agg2", f => f.Field(y => y.GroupId))))));

如何循环浏览所有InstrumentName字段,并为每个字段循环浏览所有GroupId字段?

1 个答案:

答案 0 :(得分:4)

On Nest 5.4.0

<script type="text/javascript">

var table;

$(document).ready(function() {

    //datatables
    table = $('#table').DataTable({ 
        "scrollX": true,
        "processing": true, //Feature control the processing indicator.
        "language": {
            "processing": '<div class="loading"><div class="content">\n\
                <img src="<?php echo base_url().'assets/images/loading/loading.gif'; ?>"/>\n\
            </div></div>'
        },
        "serverSide": true, //Feature control DataTables' server-side processing mode.
        "order": [], //Initial no order.
        // Load data for the table's content from an Ajax source
        "ajax": {
            "url": "<?php echo site_url('CTRL/ajax')?>",
            "type": "POST",
            "data": function(d){
                d.agent_code = "agent1";
            }
        },

        //Set column definition initialisation properties.
        "columnDefs": [
        { 
            "targets": [ 0 ], //first column / numbering column
            "orderable": false, //set not orderable
        },
        ]
    });
});

</script>