Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@egaumer
egaumer / design.sh
Created February 21, 2012 17:43
Simple Polygon Search in Cloud9
#!/bin/bash
# run this before feeding example documents
# create the collection
curl -XPUT -H 'Content-Type:application/json' 'http://localhost:2600/v1/gis'
# explicitly define the location field to be of type 'geo_point'
curl -XPUT -H 'Content-Type:application/json' 'http://localhost:2600/v1/gis/pin/_mapping' -d '{
"pin" : {
@egaumer
egaumer / filterSearch.js
Created February 23, 2012 16:24
Simple Filtered Search with Cloud9 Javascript API
/* A simple search example using the Cloud9 API */
(function($) {
/* create a query object */
var query = c9.query.QueryString("message:hello");
/* create a simple term filter that filters by user */
var filter = c9.filter.TermFilter("user", "jsmith");
/* compose the query and filter into a Lucene filterQuery */
@egaumer
egaumer / index.html
Created February 23, 2012 15:52
Simple Search with Cloud9 Javascript API
<!doctype html>
<head>
<title>Simple Search</title>
<!-- Example search template using underscore.js -->
<script type="text/template" id="results">
<% _.each(hits, function(hit) { %>
<li><%= hit._source.message %></li>
<% }); %>
</script>
@egaumer
egaumer / boolSearch.js
Last active October 1, 2015 01:27
Example boolQuery using Cloud9 Javascript API
/* fullscale.examples.elasticjs */
(function($) {
/* compose a BoolQuery out of several TermQuery objs */
var boolQuery = evo.BoolQuery()
.must(
evo.TermQuery("message", "hello"))
.mustNot(
evo.TermQuery("message", "back"))
.should(
@egaumer
egaumer / index.html
Created February 23, 2012 20:08
Example termQuery 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, function(hit) { %>
<li><%= hit._source.message %></li>
<% }); %>
</script>
@egaumer
egaumer / design-mappings.sh
Created February 23, 2012 20:26
Example nestedQuery using Cloud9 Javascript API
#!/bin/bash
# create index
curl -XPUT -H 'Content-Type:application/json' 'http://localhost:2600/v1/examples'
# setup mapping
curl -XPUT -H 'Content-Type:application/json' 'http://localhost:2600/v1/examples/nested/_mapping' -d '{
"nested": {
"properties": {
"rows": {
@egaumer
egaumer / index.html
Created February 23, 2012 21:06
Example of creating a computedProperty 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.fields.amount %></li>
<% }); %>
</script>
@egaumer
egaumer / index.html
Created February 23, 2012 21:24
Example termStatsFacet 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.product %> - <%= hit._source.quantity %></li>
<% }); %>
@egaumer
egaumer / design.sh
Created February 24, 2012 21:04
Example of geoDistance filtering with Cloud9 Javascript API
#!/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" : {
@egaumer
egaumer / design.sh
Created February 24, 2012 22:27
Example of geoDistance facet using Cloud9 Javascript API
#!/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" : {