Files
elasticsearch-js/docs/browser_builds.asciidoc
2018-07-03 12:13:10 -07:00

63 lines
2.1 KiB
Plaintext

[[browser-builds]]
== Browser Builds
We also provide builds of the elasticsearch.js client for use in the browser. These versions of the client are currently ***experimental***. We test these builds using https://saucelabs.com/u/elasticsearch-js[saucelabs] in Chrome, Firefox, and Internet Explorer 10, and 11.
While there is https://github.com/elasticsearch/elasticsearch-js/issues/96#issuecomment-42617480[a way to get it working in IE 9], the browser severely limits what you can do with cross-domain requests. Because of these limits, many of the API calls and other functionality do not work.
=== Bower
If you use bower to manage your dependencies, then just run:
[source,shell]
---------
bower install elasticsearch
---------
=== NPM
If you use npm to manage your dependencies, then just run:
[source,shell]
---------
npm install elasticsearch-browser
---------
=== Download
* v15.1.1: https://download.elasticsearch.org/elasticsearch/elasticsearch-js/elasticsearch-js-15.1.1.zip[zip], https://download.elasticsearch.org/elasticsearch/elasticsearch-js/elasticsearch-js-15.1.1.tar.gz[tar.gz]
=== Angular Build
* Registers an `esFactory` factory in the `"elasticsearch"` module
* Uses Angular's `$http` service
* Returns promises using Angular's `$q` service to properly trigger digest cycles within Angular
NOTE: Checkout an example that integrates elasticsearch.js with angular https://github.com/spenceralger/elasticsearch-angular-example[on GitHub]
.Include the `"elasticsearch"` module in your app
[source,js]
-------------------
var myApp = angular.module('myApp', ['elasticsearch']);
-------------------
.Create a client instance and register it as a service
[source,js]
-------------------
module.service('client', function (esFactory) {
return esFactory({
host: 'localhost:9200',
// ...
});
});
-------------------
=== jQuery Build
* Uses jQuery's `.ajax()` functionality
* Returns jQuery "promises"
* Registers the module at `jQuery.es`
.Create a client with the jQuery build
[source,js]
-------------------
var client = new $.es.Client({
hosts: 'localhost:9200'
});
-------------------