A Library To Manage Operations On ElasticSearch.
npm install @idio/elastic
@idio/elastic Is A Library To Manage Operations On ElasticSearch.
``sh`
yarn add -E @idio/elastic
- Table Of Contents
- API
- [async search(client: Client, searchParams: SearchParams, queryParams?: Object): Hits[]](#async-searchclient-clientsearchparams-searchparamsqueryparams-object-hits)Hit
*
- Copyright
The package is available by importing its components functions:
`js`
import { search } from '@idio/elastic'
client: Client,
searchParams: SearchParams,
queryParams?: Object,
): Hits[]The wrapper around search to make a query based on a data object. Returns an empty array no no hits are found.
import('elasticsearch').Client __Client__
import('elasticsearch').SearchParams __SearchParams__
__Hit__
| Name | Type | Description |
| --------------- | ------------- | ---------------------------------------- |
| ___id*__ | _string_ | DQn4JC6q5zZQsgv5KNhiWlgd |idio-example
| ___index*__ | _string_ | |1
| ___score*__ | _number_ | |Object {name: "example", user: "idio"}
| ___source__ | __ | |doc
| ___type*__ | _string_ | |
| _version | _number_ | |
| _explanation | _Explanation_ | |
| fields | _*_ | |
| highlight | _*_ | |
| inner_hits | _*_ | |
| matched_queries | _string[]_ | |
| sort | _string[]_ | |
`js
const INDEX = 'idio-example'
;(async () => {
// 1. Create a record in ElasticSearch for the example.
const { id, client } = await getClient()
const res = await search(client, {
index: INDEX,
type: 'doc',
}, { _id: id })
console.log(res)
})()
````
[ { _index: 'idio-example',
_type: 'doc',
_id: '7Tn79YCXy9lKoxQi7l9k0SHq',
_score: 1,
_source:
{ name: 'example',
user: 'idio',
date: '2018-11-15T15:57:52.031Z' } } ]
(c) [Idio][1] 2018
[1]: https://idio.cc