forked from danpaz/bodybuilder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
83 lines (76 loc) · 3.11 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<html>
<head>
<title>Bodybuilder | An elasticsearch query body builder</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="assets/codemirror.css">
<link rel="stylesheet" href="assets/styles.css">
<link rel="icon" type="image/x-icon" href="assets/favicon.ico" />
</head>
<body>
<div class="bb_headers">
<img class="bb_logo" src="assets/ic-logo.png" alt="bodybuilder">
<h1 class="bb_h1">Bodybuilder</h1>
<h2 class="bb_h2">
An elasticsearch query body builder.
Easily build complex queries for elasticsearch with a simple, predictable api.
</h2>
<div class="bb_buttons">
<a class="bb_button-docs" href="/docs">
<img class="bb_icon-github" src="assets/ic-docs.png" alt="Documentation">
<span>Read the Docs</span>
</a>
<a class="bb_button-github" href="https://github.com/danpaz/bodybuilder">
<img class="bb_icon-github" src="assets/ic-github.png" alt="github">
<span>View on GitHub</span>
</a>
</div>
</div>
<div class="bb_textareas">
<div class="bb_textarea">
<div id="input_textarea"></div>
</div>
<div class="bb_textarea">
<div id="output_textarea"></div>
</div>
</div>
<div>
<a href="https://www.npmjs.com/package/bodybuilder"><img src="https://img.shields.io/npm/v/bodybuilder.svg?link=http://left"></a>
<a href="https://www.npmjs.com/package/bodybuilder"><img src="https://img.shields.io/npm/dm/bodybuilder.svg?style=flat&link=http://npmjs.org/danpaz/bodybuilder"></a>
<a href="https://github.com/danpaz/bodybuilder"><img src="https://img.shields.io/github/stars/danpaz/bodybuilder.svg?style=social&link=http://github.com/danpaz/bodybuilder"></a>
</div>
<script type="text/javascript" src="browser/bodybuilder.min.js" charset="utf-8"></script>
<script src="assets/codemirror-compressed.js"></script>
<script>
var inputTextarea = document.getElementById('input_textarea');
var outputTextarea = document.getElementById('output_textarea');
var inputEditor = CodeMirror(inputTextarea, {
lineNumbers: true,
placeholder: 'Type a query...',
});
var outputEditor = CodeMirror(outputTextarea, {
lineNumbers: true,
readOnly: true,
});
function onInputChange(cm, change) {
var input = inputEditor.getValue().trim();
try {
var newOutput = eval(input);
var json = JSON.stringify(newOutput, null, 2);
outputEditor.setValue(json);
} catch (err) {
outputEditor.setValue(err.toString());
console.error('invalid input', err);
}
}
inputEditor.on('change', onInputChange);
inputEditor.setValue(`bodybuilder()
.query('match', 'message', 'this is a test')
.filter('term', 'user', 'kimchy')
.filter('term', 'user', 'herald')
.orFilter('term', 'user', 'johnny')
.notFilter('term', 'user', 'cassie')
.aggregation('terms', 'user')
.build()`);
</script>
</body>
</html>