Skip to content

Instantly share code, notes, and snippets.

@egaumer
egaumer / directives.js
Created Jul 3, 2013
Angular directives for autocomplete and range slider.
View directives.js
"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
Elasticsearch/AngularJS Pagination Example
View controller.js
$scope.pager = {
pageChange: function(pageNum) {
$scope.search(resultPager.get(pageNum));
},
next: function() {
this.pageChange(resultPager.next());
},
@egaumer
egaumer / app.js
Last active Jul 24, 2018
Getting Started with elasticsearch and AngularJS
View app.js
/*jshint globalstrict:true */
/*global angular:true */
'use strict';
angular.module('demo', [
'demo.controllers',
'demo.directives',
'elasticjs.service'
]);
@egaumer
egaumer / DSL Examples
Last active Jun 26, 2019
Some example queries using elastic.js
View DSL Examples
# simple match all query with term facet
ejs.Request()
.indices("myindex")
.types("mytype")
.query(ejs.MatchAllQuery())
.facet(
ejs.TermsFacet('url')
.field('url')
.size(20))
@egaumer
egaumer / toAtom.js
Created Dec 22, 2012
Example of how to generate Atom feeds with E4X.
View toAtom.js
/* 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 / session.js
Last active Oct 1, 2015
Basic session handling with evo server-side javascript controllers
View session.js
/* 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 / index.html
Created Mar 2, 2012
Example of storing and retrieving a document by its id with the Cloud9 Javascript API
View index.html
<!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 / index.html
Created Feb 26, 2012
Example Span queries using Cloud9 Javascript API
View index.html
<!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 Feb 25, 2012
Example of dateHistogramFacet using Cloud9 Javascript API
View index.html
<!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 / design.sh
Created Feb 24, 2012
Example of geoDistance facet using Cloud9 Javascript API
View design.sh
#!/bin/bash
# run this before feeding example documents
# create the collection
curl -XPUT -H 'Content-Type:application/json' 'http://localhost:2600/v1/restaurant'
# explicitly define the location field to be of type 'geo_point'
curl -XPUT -H 'Content-Type:application/json' 'http://localhost:2600/v1/restaurant/locations/_mapping' -d '{
"locations" : {