https://github.com/frenchbread/meteor-elastic-rest
:mag_right: Wrapper for ElasticSearch API.
https://github.com/frenchbread/meteor-elastic-rest
Last synced: about 1 month ago
JSON representation
:mag_right: Wrapper for ElasticSearch API.
- Host: GitHub
- URL: https://github.com/frenchbread/meteor-elastic-rest
- Owner: frenchbread
- License: mit
- Created: 2015-07-06T11:01:11.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-05-25T14:24:49.000Z (almost 9 years ago)
- Last Synced: 2025-02-11T19:36:43.644Z (3 months ago)
- Language: JavaScript
- Homepage: https://atmospherejs.com/frenchbread/elastic-rest
- Size: 20.5 KB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# elastic-rest
Wrapper for Elastic Search REST API based on elasticsearch [npm package](https://www.npmjs.com/package/elasticsearch).
See ES [docs](https://www.elastic.co/guide/index.html).
## Installation
```
$ meteor add frenchbread:elastic-rest
```## Usage
#### Setup:
```javascript
var config = {
host: "http://elasticsearch.example.com:14002"
};var options = {
index: 'search_index',
type: 'search_type',
size: 10,
from: 0,
query: {
match_all: {}
},
fields: [
'field_one',
'field_two',
'field_three',
'field_four',
],
sort: [{'field_one':'desc'}]
};var es = new ElasticRest(config, options);
es.doSearch();
```or
```javascript
// initialize without query options
var config = {
host: "http://elasticsearch.example.com:14002"
};
var es = new ElasticRest(config);// and pass options as parameter at the time of querying
var options = {
index: 'search_index',
type: 'search_type',
size: 10,
from: 0,
query: {
match_all: {}
},
fields: [
'field_one',
'field_two',
'field_three',
'field_four',
],
sort: [{'field_one':'desc'}]
};es.doSearch(options);
```#### Sample output:
```javascript
{
took: 159,
timed_out: false,
_shards: {
total: 3,
successful: 3,
failed: 0
},
hits:
{
total: 16927,
max_score: 1,
hits:
[
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object],
[Object]
]
}
}```
## License
[MIT](https://github.com/frenchbread/meteor-elastic-rest/blob/master/LICENSE)