0.2.0 • Published 7 years ago
@idio/elastic v0.2.0
@idio/elastic
@idio/elastic Is A Library To Manage Operations On ElasticSearch.
yarn add -E @idio/elasticTable Of Contents
- Table Of Contents
- API
async search(client: Client, searchParams: SearchParams, queryParams?: Object): Hits[]- Copyright
API
The package is available by importing its components functions:
import { search } from '@idio/elastic'async search( 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 |
| _index* | string | idio-example |
| _score* | number | 1 |
| _source* | * | Object {name: "example", user: "idio"} |
| _type* | string | doc |
| _version | number | |
| _explanation | Explanation | |
| fields | * | |
| highlight | * | |
| inner_hits | * | |
| matched_queries | string[] | |
| sort | string[] |
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' } } ]Copyright
(c) Idio 2018