@idio/elastic

0.2.0 • Public • Published

@idio/elastic

npm version

@idio/elastic Is A Library To Manage Operations On ElasticSearch.

yarn add -E @idio/elastic

Table Of Contents

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

/@idio/elastic/

    Package Sidebar

    Install

    npm i @idio/elastic

    Weekly Downloads

    0

    Version

    0.2.0

    License

    MIT

    Unpacked Size

    7.85 kB

    Total Files

    8

    Last publish

    Collaborators

    • zvr