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; |
View controller.js
$scope.pager = { | |
pageChange: function(pageNum) { | |
$scope.search(resultPager.get(pageNum)); | |
}, | |
next: function() { | |
this.pageChange(resultPager.next()); | |
}, |
View app.js
/*jshint globalstrict:true */ | |
/*global angular:true */ | |
'use strict'; | |
angular.module('demo', [ | |
'demo.controllers', | |
'demo.directives', | |
'elasticjs.service' | |
]); |
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)) |
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"; |
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 */ |
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> |
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> |
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> | |
<% }); %> |
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" : { |
NewerOlder