Skip to content

Instantly share code, notes, and snippets.

@egaumer
egaumer / index.html
Created February 25, 2012 01:59
Example of dateHistogramFacet using Cloud9 Javascript API
<!doctype html>
<head>
<title>Simple Search</title>
<!-- Example search template using underscore.js -->
<script type="text/template" id="results">
<% _.each(hits.hits, function(hit) { %>
<li><%= hit._source.title %> published on <%= hit._source.date %></li>
<% }); %>
@egaumer
egaumer / index.html
Created February 26, 2012 17:23
Example Span queries using Cloud9 Javascript API
<!doctype html>
<head>
<title>Simple Search</title>
<!-- Example search template using underscore.js -->
<script type="text/template" id="results">
<% _.each(hits.hits, function(hit) { %>
<li><%= hit._source.text %></li>
<% }); %>
</script>
@egaumer
egaumer / index.html
Created March 2, 2012 22:49
Example of storing and retrieving a document by its id with the Cloud9 Javascript API
<!doctype html>
<head>
<title>Simple Search</title>
<!-- Example search template using underscore.js -->
<script type="text/template" id="results">
<li><%= title %></li>
</script>
</head>
@egaumer
egaumer / session.js
Last active October 1, 2015 19:38
Basic session handling with evo server-side javascript controllers
/* the controller */
function session() {
function doGet(session) {
return { body: ["This method is public"] };
}
function doPut(session) {
if (!session) {
/* user not logged in - send redirect */
@egaumer
egaumer / toAtom.js
Created December 22, 2012 15:42
Example of how to generate Atom feeds with E4X.
/* the controller */
function blog() {
function toAtom(results) {
default xml namespace = "http://www.w3.org/2005/Atom";
var feed = <feed/>;
feed.id = "http://host.com/feeds/blog/atom";
feed.title = "Sample Atom Feed";
feed.author.name = "Jon Smith";
feed.author.email = "jsmith@host.com";
@egaumer
egaumer / directives.js
Created July 3, 2013 13:48
Angular directives for autocomplete and range slider.
"use strict";
angular.module('fs.directives', [])
.directive('rangeSlider', function() {
return {
restrict: 'A',
link: function(scope, element, attrs) {
var min = parseInt(attrs.min, 10) || 0;
var max = parseInt(attrs.max, 10) || 100;
@egaumer
egaumer / controller.js
Created May 14, 2013 11:20
Elasticsearch/AngularJS Pagination Example
$scope.pager = {
pageChange: function(pageNum) {
$scope.search(resultPager.get(pageNum));
},
next: function() {
this.pageChange(resultPager.next());
},
@egaumer
egaumer / app.js
Last active July 24, 2018 13:25
Getting Started with elasticsearch and AngularJS
/*jshint globalstrict:true */
/*global angular:true */
'use strict';
angular.module('demo', [
'demo.controllers',
'demo.directives',
'elasticjs.service'
]);
@egaumer
egaumer / DSL Examples
Last active June 26, 2019 20:21
Some example queries using elastic.js
# simple match all query with term facet
ejs.Request()
.indices("myindex")
.types("mytype")
.query(ejs.MatchAllQuery())
.facet(
ejs.TermsFacet('url')
.field('url')
.size(20))