spalger / elasticsearch-angular-example Goto Github PK
View Code? Open in Web Editor NEWThis is a very simple project designed to help people get going with angular and elasticsearch.
This is a very simple project designed to help people get going with angular and elasticsearch.
If you want to run this locally you will probably need to add
http.cors.enabled: true
to elasticsearch.yml
How do you use the angular service to do a suggest and pass in the data like below:
curl -X POST 'localhost:9200/music/_suggest?pretty' -d '{
"song-suggest" : {
"text" : "n",
"completion" : {
"field" : "suggest"
}
}
}'
Is there a place where once can see all the possible ways of using the Angular Service?
I can get it to work in 'Sense' following the documentation below:
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-completion.html
Thanks
when i run this app i get the following error....
elasticsearch.angular.min.js:7 Uncaught Error: Cannot find module '__browserify_process'
index.html:33
Uncaught ReferenceError: require is not defined
angular.js:4587
Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.5.5/$injector/modulerr?p0=ExampleApp&p1=Error…search-angular-example%2Fnode_modules%2Fangular%2Fangular.min.js%3A21%3A19)
please help...
Hello
I am using elasticsearch module on AngularJs project.
I am trying to use GET method but it works on POST method.
How can I change the method type from post to get.
angular.module('testApp')
.service('OurService', function ($http, $window, esFactory) {
function getData() {
return esFactory({
host: 'localhost:9200',
log: 'trace'
});
};
return ({
getData: getData
});
});
angular.module('testApp')
.controller('MainCtrl', function ($scope, OurService, esFactory) {
$scope.getCurrencyDataFromCurrencylayer = function() {
var client = OurService.getData();
console.log(client);
client.search().then(function (resp) {
console.log(resp);
}, function (err) {
console.log(err);
});
};
$scope.getCurrencyDataFromCurrencylayer();
});
I've been trying to set things up using the latest version of elasticsearch.js based off this example.
I can't seem to get anywhere I keep getting:
XMLHttpRequest cannot load http://localhost:9200/. The 'Access-Control-Allow-Origin' header contains the invalid value 'null'. Origin 'http://elasticsearch-angular-example.dev' is therefore not allowed access.
This is how I am calling up the client:
ExampleApp.service('client', function (esFactory) {
return esFactory({
host: {
protocol: 'http',
host: localhost',
port: 9200,
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
}
});
});
Oddly enough if I drag and drop the index.html it seems not to care. But in every other environment it turns up null.
Follow your guideline, by adding
http.cors: enabled: true allow-origin: /https?:\/\/localhost(:[0-9]+)?/
(My elasticsearch.yml follow yaml syntax)
into elasticsearch.yml
by running the index.html I got a error message in Chrome Console
XMLHttpRequest cannot load http://localhost:9200/_cluster/state/cluster_name%2Cnodes%2Cmaster_node%2Cversion. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. The response had HTTP status code 403. XMLHttpRequest cannot load http://localhost:9200/_cluster/state/cluster_name%2Cnodes%2Cmaster_node%2Cversion. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. The response had HTTP status code 403.
Have you got other way to config cors for elasticsearch?.
I am using Ubuntu 14.04 and elastic 2.3.1
I m trying to use the elastic-search-angular client in angular app which i m trying to build using webpack with es6.
When i load the elastic-search-angular
import angularElasticsearch from 'elasticsearch-browser';
I get this in npm start
WARNING in ./~/elasticsearch-browser/elasticsearch.js
Critical dependencies:
7:418-425 This seems to be a pre-built javascript file. Though this is possible, it's not recommended. Try to require the original source to get better results.
@ ./~/elasticsearch-browser/elasticsearch.js 7:418-425
And the browser complains:
Error: [$injector:modulerr] Failed to instantiate module function es() due to:
Error: Looks like you are expecting the previous "elasticsearch" module. It is now the "es" module. To create a client with this module use `new es.Client(params)`.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.