Skip to content
This repository was archived by the owner on Nov 15, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 26 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ Here is an example HTML file defining a Kendo grid talking to ElasticSearch:
<html>
<head>
<title>ElasticSearch Kendo DataSource example</title>
<link href="kendo.common.min.css" rel="stylesheet">
<link href="http://cdn.kendostatic.com/2014.1.318/styles/kendo.common.min.css" rel="stylesheet">
<link href="http://cdn.kendostatic.com/2014.1.318/styles/kendo.default.min.css" rel="stylesheet">

<!-- Include dependencies -->
<script src="moment.min.js"></script>
<script src="jquery.min.js"></script>
<script src="kendo.web.min.js"></script>
<!-- Include dependencies -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.3/moment.min.js"></script>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="http://cdn.kendostatic.com/2014.1.318/js/kendo.web.min.js"></script>

<!-- Include kendo-elasticsearch itself -->
<script src="kendo-elasticsearch.js"></script>
<!-- Include kendo-elasticsearch itself -->
<script src="kendo-elasticsearch.js"></script>

</head>
<body>
Expand All @@ -40,6 +41,9 @@ Here is an example HTML file defining a Kendo grid talking to ElasticSearch:
// point it to the URL where ElasticSearch search requests can go
transport: {
read: {
//other urls:
// http://localhost:9200/logstash-*/_search/
// http://localhost:9200/index1,index2,index3/_search/
url: "http://localhost:9200/_all/_search/"
}
},
Expand All @@ -51,18 +55,28 @@ Here is an example HTML file defining a Kendo grid talking to ElasticSearch:
model: {
fields: {
message: { type: "string" },
event_data_timestamp: { type:"datetime", esName:"event.data.timestamp"},
other: { type:"string"},

// you can specify a different ElasticSearch name for the field,
// to deal with ElasticSearch field names that Kendo can't handle
timestamp: { type: "date", esName: "@timestamp" }
timestamp: { type: "datetime", esName: "@timestamp" }
}
}
},

// server-side paging, filtering and sorting are enabled by default.
// Set filters as you like
sort: { field: "timestamp", dir: "desc" },
filter: { field: "message", operator: "eq", value: "accepted" }
filter: [
{
"logic":"and",
"filters":[
{ field: "message", operator: "eq", value: "accepted" },
{ field: "other", operator: "neq", value: "0" }
]
}
]
}),

// other grid options besides the datasource
Expand All @@ -71,7 +85,9 @@ Here is an example HTML file defining a Kendo grid talking to ElasticSearch:
filterable: true,
columns: [
{ field: "timestamp" },
{ field: "message" }
{ field: "message" },
{ field: "event_data_timestamp"},
{ field: "other"}
]
});
});
Expand Down
16 changes: 14 additions & 2 deletions kendo-elasticsearch.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

/**
* A Kendo DataSource that gets its data from ElasticSearch.
*
Expand Down Expand Up @@ -72,7 +73,18 @@

dataItem.id = hits[i]._id;
for (var k in self._esFieldMap) {
dataItem[k] = hitSource[self._esFieldMap[k]];
var nameSplit = self._esFieldMap[k].split(".");
if (nameSplit.length > 1) {
var temp = hitSource;
for (var l in nameSplit) {
temp = temp[nameSplit[l]];
if (temp == undefined)
break;
}
dataItem[k] = temp;
}
else
dataItem[k] = hitSource[self._esFieldMap[k]];
}

dataItems.push(dataItem);
Expand Down Expand Up @@ -162,4 +174,4 @@
}
})

})(window.kendo);
})(window.kendo);