Higher level client for Elasticsearch written in Node.js oriented on facets and simplicity
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
tests
.gitignore
.npmignore
LICENSE
README.md
index.js
package-lock.json
package.json
yarn.lock

README.md

ElasticItems

Higher level client for Elasticsearch in Node.js oriented on facets. It's a compact version of ItemsAPI without API.

Features

  • faceted search
  • full text
  • pagination
  • big data support

Getting Started

npm install elasticitems
const elasticitems = require('elasticitems')(es_config, search_config);
elasticitems.search()
.then(result => {
  console.log(result);
})

API

var elasticitems = ElasticItems(es_config, [search_config])

es_config

The first es_config is elasticsearch configuration object and contains values like host, index or type.

search_config

Responsible for defining global configuration.

  • aggregations filters configuration i.e. for tags, actors, colors, etc. Responsible for generating facets.

  • sortings you can configure different sortings like tags_asc, tags_desc with options and later use it with one key.

elasticitems.search(options, [search_config])

options

  • per_page amount of items per page.

  • page page number - used for pagination.

  • query used for full text search.

  • operator search operator and and or (default). It works with query parameter

  • sort used for sorting. one of sortings key

  • filters filtering items based on specific aggregations i.e. {tags: ['drama' , 'historical']}

  • query_string i.e. "brand:Audi OR brand:Mercedes"

  • fields search only in specifc fields i.e. ['name', 'description']. Missing parameter means search in all fields

elasticitems.similar(id, options)

Show similar items based on collaborative filtering

options

  • fields i.e ['tags'].

elasticitems.aggregation(options)

It returns full list of filters for specific aggregation

options

  • name aggregation name

  • per_page filters per page

  • size how much load into memory (for pagination)

  • page page number

  • sort responsible for sorting mechanism. It can be _count or _term

  • order responsible for an order. It can be asc or desc

  • filters filter this aggregation through another aggregations (facets)

  • aggregation_query used for quering filters. It's not full text search

  • query search through items

  • query_string search through items by query string i.e. (category:Garden and color:red)

elasticitems.get(id)

Returns found record otherwise throw an error

elasticitems.getBy(key, value)

Returns record based on key and value

elasticitems.add(data, [options])

Add a new object into index. Provide your own id if you don't want it auto-generated

elasticitems.partialUpdate(id, data, [options])

Updates object in index

elasticitems.delete(id)

Delete object from index