0.2.0 • Published 5 years ago

@idio/elastic v0.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

@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

NameTypeDescription
_id*stringDQn4JC6q5zZQsgv5KNhiWlgd
_index*stringidio-example
_score*number1
_source**Object {name: "example", user: "idio"}
_type*stringdoc
_versionnumber
_explanationExplanation
fields*
highlight*
inner_hits*
matched_queriesstring[]
sortstring[]
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