CARVIEW |
Select Language
HTTP/2 200
date: Fri, 25 Jul 2025 00:38:52 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
etag: W/"2b001fded167155e24b315600a866a1b"
cache-control: max-age=0, private, must-revalidate
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: origin-when-cross-origin, strict-origin-when-cross-origin
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
content-encoding: gzip
accept-ranges: bytes
set-cookie: _gh_sess=giA35gfrsXfV6nMe4FLLXeFn4LgYUINDH1EClC%2FKciEX0CKblOc%2FKBGmeXM2lZs2uUbHRiDaHsfYAAbhf0KE9nOmoMvhAPM%2BqSCkhdF9LPdzsTyr%2FKi%2Fwpub0JylyaV%2F4nugfLGiC8BmETd478b5tSq5PZMSovhT3tGgqz6QoO43xAoF8Ql4WXuWqCNNWoX973dfiqHkBoP0wk7Hv29nlFPEz6sSTUvX8H1TJIHi42pEBPRI8nCGrxfoWC1S2xl4310qpkwwGeKyJpVhHrFFNg%3D%3D--X6RwEYNqpYdQeUJI--YWYuddI7LvSGg15OhnYtpw%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.525757034.1753403931; Path=/; Domain=github.com; Expires=Sat, 25 Jul 2026 00:38:51 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Sat, 25 Jul 2026 00:38:51 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: 9AC0:167D14:4BCE0:77A2C:6882D21B
Getting Started with elasticsearch and AngularJS · GitHub
Show Gist options
Save egaumer/5101149 to your computer and use it in GitHub Desktop.
{{ message }}
Instantly share code, notes, and snippets.
-
Star
22
(22)
You must be signed in to star a gist -
Fork
10
(10)
You must be signed in to fork a gist
-
Save egaumer/5101149 to your computer and use it in GitHub Desktop.
Getting Started with elasticsearch and AngularJS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*jshint globalstrict:true */ | |
/*global angular:true */ | |
'use strict'; | |
angular.module('demo', [ | |
'demo.controllers', | |
'demo.directives', | |
'elasticjs.service' | |
]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*jshint globalstrict:true */ | |
/*global angular:true */ | |
'use strict'; | |
/* controller.js */ | |
angular.module('demo.controllers', []) | |
.controller('SearchCtrl', function($scope, ejsResource) { | |
var ejs = ejsResource('https://localhost:9200'); | |
var QueryObj = ejs.QueryStringQuery().defaultField('Title'); | |
var activeFilters = {}; | |
var client = ejs.Request() | |
.indices('stackoverflow') | |
.types('question') | |
.facet( | |
ejs.TermsFacet('tags') | |
.field('Tags') | |
.size(10)); | |
$scope.isActive = function (field, term) { | |
return activeFilters.hasOwnProperty(field + term); | |
}; | |
var applyFilters = function(query) { | |
var filter = null; | |
var filters = Object.keys(activeFilters).map(function(k) { return activeFilters[k]; }); | |
if (filters.length > 1) { | |
filter = ejs.AndFilter(filters); | |
} else if (filters.length === 1) { | |
filter = filters[0]; | |
} | |
return filter ? ejs.FilteredQuery(query, filter) : query; | |
}; | |
$scope.search = function() { | |
$scope.results = client | |
.query(applyFilters(QueryObj.query($scope.queryTerm || '*'))) | |
.doSearch(); | |
}; | |
$scope.filter = function(field, term) { | |
if ($scope.isActive(field, term)) { | |
delete activeFilters[field + term]; | |
} else { | |
activeFilters[field + term] = ejs.TermFilter(field, term); | |
} | |
$scope.search(); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*jshint globalstrict:true */ | |
/*global angular:true */ | |
angular.module('demo.directives', []) | |
.directive('bar', function() { | |
return { | |
restrict: 'E', | |
scope: { | |
onClick: '=', | |
bind: '=', | |
field: '@' | |
}, | |
link: function(scope, element, attrs) { | |
var width = 300; | |
var height = 250; | |
var x = d3.scale.linear().range([0, width]); | |
var y = d3.scale.ordinal().rangeBands([0, height], .1); | |
var svg = d3.select(element[0]) | |
.append('svg') | |
.attr('preserveAspectRatio', 'xMaxYMin meet') | |
.attr('viewBox', '0 0 ' + (width + 75) + ' ' + height) | |
.append('g'); | |
scope.$watch('bind', function(data) { | |
if (data) { | |
x.domain([0, d3.max(data, function(d) { return d.count; })]); | |
y.domain(data.map(function(d) { return d.term; })); | |
var bars = svg.selectAll('rect') | |
.data(data, function(d, i) { return Math.random(); }); | |
// d3 enter fn binds each new value to a rect | |
bars.enter() | |
.append('rect') | |
.attr('class', 'bar rect') | |
.attr('y', function(d) { return y(d.term); }) | |
.attr('height', y.rangeBand()) | |
.attr('width', function(d) { return x(d.count); }); | |
// wire up event listeners - (registers filter callback) | |
bars.on('mousedown', function(d) { | |
scope.$apply(function() { | |
(scope.onClick || angular.noop)(scope.field, d.term); | |
}); | |
}); | |
// d3 exit/remove flushes old values (removes old rects) | |
bars.exit().remove(); | |
var labels = svg.selectAll('text') | |
.data(data, function(d) { return Math.random(); }); | |
labels.enter() | |
.append('text') | |
.attr('y', function(d) { return y(d.term) + y.rangeBand() / 2; }) | |
.attr('x', function(d) { return x(d.count) + 3; }) | |
.attr('dy', '.35em') | |
.attr('text-anchor', function(d) { return 'start'; }) | |
.text(function(d) { return d.term + ' (' + d.count + ')'; }); | |
// d3 exit/remove flushes old values (removes old rects) | |
labels.exit().remove(); | |
} | |
}) | |
} | |
}; | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html ng-app="demo"> | |
<head> | |
<link rel="stylesheet" href="common/css/bootstrap.min.css"> | |
<!-- project dependency libs --> | |
<script src="common/lib/angular.min.js"></script> | |
<script src="common/lib/d3.min.js"></script> | |
<script src="common/lib/elastic.min.js"></script> | |
<script src="common/lib/elastic-angular-client.min.js"></script> | |
<!-- project specific files --> | |
<script src="js/app.js"></script> | |
<script src="js/controllers.js"></script> | |
<script src="js/directives.js"></script> | |
<style>.bar.rect { fill: #058dc7; stroke: none; }</style> | |
</head> | |
<body ng-controller="SearchCtrl"> | |
<div class="container-fluid"> | |
<div class="row-fluid"> | |
<span class="span3"> | |
<input class="input-block-level" ng-model="queryTerm" type="text"> | |
</span> | |
<button ng-click="search()" class="btn" type="button">Search</button> | |
</div> | |
<div class="row-fluid"> | |
<div class="span2"> | |
<div ng-repeat="entry in results.facets.tags.terms"> | |
<a ng-click="filter('Tags', entry.term)"> | |
<i class="icon-remove-sign" ng-show="isActive('Tags', entry.term)"></i> {{ entry.term }} | |
</a> {{ entry.count }} | |
</div> | |
</div> | |
<div class="span3"> | |
<bar bind="results.facets.tags.terms" on-click="filter" field="Tags" /> | |
</div> | |
<div class="span4"> | |
<li ng-repeat="doc in results.hits.hits"> | |
{{ doc._source.Title }} | |
</li> | |
</div> | |
</div> | |
</div> | |
</body> | |
</html> |
how can I run this code ???
not work:
TypeError: undefined is not a function
at new (https://127.0.0.1:8000/static/js/controllers.js:17:14)
controllers.js line 16 to 22
var client = ejs.Request()
.indices('stackoverflow')
.types('question')
.facet(
ejs.TermsFacet('tags')
.field('Tags')
.size(10));
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can’t perform that action at this time.
index.html :
<script src="js/controllers.js"></script> should be <script src="js/controller.js"></script>