Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/elastic/bower-elasticsearch-js
Elasticsearch client for the browser
https://github.com/elastic/bower-elasticsearch-js
Last synced: 27 days ago
JSON representation
Elasticsearch client for the browser
- Host: GitHub
- URL: https://github.com/elastic/bower-elasticsearch-js
- Owner: elastic
- License: apache-2.0
- Created: 2013-12-03T02:55:35.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2024-08-08T07:49:54.000Z (3 months ago)
- Last Synced: 2024-10-04T06:05:45.574Z (about 1 month ago)
- Language: JavaScript
- Homepage: https://github.com/elastic/elasticsearch-js-legacy
- Size: 10.1 MB
- Stars: 64
- Watchers: 348
- Forks: 30
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# elasticsearch
Elasticsearch client builds for bower.
# Install
Install with `bower`
```
bower install elasticsearch
```Add a `` to your html file and off you go!:
```
<script src="/bower_components/elasticsearch/elasticsearch.js">var client = elasticsearch.Client({
host: 'localhost:9200'
});```
## If you are using AngularJS
Use `elasticsearch.angular.js` instead. This will create an `elasticsearch` module with an `esFactory` that you can use.
```
/*
* create your app module, specify "elasticsearch" as a dependency
*/
var app = angular.module('myApp', ['elasticsearch']);/*
* create a service, which provides your elasticsearch client
* to other parts of your application
*/
app.service('es', function (esFactory) {
return esFactory({
host: 'localhost:9200',
// ...
});
});
```
## If you are using Angular2+
in your module:```typescript
import * as es from 'elasticsearch-browser/elasticsearch'@NgModule({
providers: [
{
provide: 'elasticsearch',
useFactory: () => {
return new es.Client({
host: 'https://localhost:9200',
});
},
deps: [],
}
]
})
export class AppModule {}
```in your service:
```typescript
export class ExampleService {
constructor(@Inject('elasticsearch') private readonly elasticClient) {}
}
```## If you are using jQuery
Use `elasticsearch.jquery.js` instead. Rather than a global `elasticsearch` it will create a `jQuery.es` namespace.
```
var client = new $.es.Client({
hosts: 'localhost:9200'
});
```# Submit Issues, Pull Requests, etc to [elasticsearch-js](https://github.com/elasticsearch/elasticsearch-js).