我正在尝试将函数从elasticsearch实例运行到datatables以显示结果。 但问题是我无法在数据表中显示它
<head>
<script src="//cdnjs.cloudflare.com/ajax/libs/datatables/1.10.8/js/jquery.dataTables.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/datatables/1.10.8/js/dataTables.bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/datatables/1.10.8/js/dataTables.jqueryui.min.js"></script>
<script src="//cdn.datatables.net/responsive/1.0.6/js/dataTables.responsive.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/datatables/1.10.8/js/dataTables.bootstrap.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/elasticsearch/10.0.1/elasticsearch.min.js"></script>
<script>
var client = elasticsearch.Client({
host: 'localhost:9200'
});
$('#example').dataTable( {
'columns': [
{ 'sTitle': 'timestamp', 'sName': 'timestamp' },
{ 'sTitle': 'message', 'sName': 'message' }
],
'bProcessing': true,
'bServerSide': true,
'fnServerData': $.fn.dataTable.elastic_datatables( {
index: 'logstash-log-*',
type: 'log',
client: client,
body: {
query: {
"bool": {
"must": [{
"term": {
"user": <?php echo $user;>
}
},
{
"range": {
"timestamp": {
"from":<?php echo $from;>,
"to":<?php echo $to;>
}
}
},
{
"query_string": {
"default_field": "_all",
"query": "*"
}
}
]}
}
}
} )
} );
</head>
<body>
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th ></th>
<th >timestamp</th>
<th >message</th>
</tr>
</thead>
<tfoot>
<tr>
<th></th>
<th>timestamp</th>
<th>message</th>
</tr>
</tfoot>
</table>
</body>
</html>
这是用于jquery.elastic-datatables.js https://github.com/pidupuis/elastic-datatables的包 任何帮助将不胜感激!