New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

contexture-elasticsearch

Package Overview
Dependencies
Maintainers
1
Versions
187
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

contexture-elasticsearch

ElasticSearch Provider for Contexture

  • 0.0.8
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
131
increased by1.55%
Maintainers
1
Weekly downloads
 
Created
Source

contexture-elasticsearch

Elasticsearch Provider for Contexture

Usage

This provider takes a config object as a parameter, and expects a getClient method to be provided, which should be an instantiated elasticsearch client.

Provider

This provider takes a config object as a parameter:

OptionTypeDescriptionRequired
getClientfunctionReturns an instantiated elasticsearch clientx
requestobjectMerged in the json body of every request to elasticsearch (e.g. to add custom headers)
typesobjectContexture node types, like all other providers

Schemas

Schemas with with an elasticsearch provider can specify any or all of the following properties:

OptionTypeDescriptionRequired
indexstringWhich ES index to use when queryingx
typestringWhich ES type to use when querying
summaryViewfunctionUsed by results to return a summary view instead of the whole document, (e.g. for indexes with many fields). Defaults to returning the hit property.
highlightobject Used by results to determine what fields to highlight, and whether or not they are inline (copied over inline on to the source) or additional (in a list of additional fields that matched)

Example Schema for SomeType in SomeIndex

module.exports = {
  elasticsearch: {
    index: 'SomeIndex',
    type: 'SomeType'
  }
}

Seting up contexture

let _ = require('lodash')
let Contexture = require('contexture')
let provider = require('contexture-elasticsearch')
let types = require('contexture-elasticsearch/types')
let schemas = require('./path/to/schemas')
let elasticsearch = require('elasticsearch')
let AgentKeepAlive  = require('agentkeepalive'),

let process = Contexture({
  schemas,
  providers: {
    elasticsearch: provider({
      getClient: _.memoize(() =>
        elasticsearch.Client({
          // This is an example config, see the elasticsearch js docs for more
          minSockets: 1,
          maxSockets: 20,
          keepAlive: true,
          createNodeAgent: (connection, config) =>
            new AgentKeepAlive(connection.makeAgentConfig(config))
        })
      ),
      request: {
        headers: {
          'custom-header-app-name': 'my-app-sent-this'
        }
      },
      types: types({
        geo: {
          geocodeLocation: query =>
            googleplaces.textSearch({
              query
            })
        }
      })
    })
  }
})

Default Types

bool

cardinality

date

dateHistogram

esTwoLevelAggregation

exists

facet

geo

groupedMetric

matchCardinality

matchStats

nLevelAggregation

nonzeroClusters

number

percentileRanks

percentiles

percentilesRange

query

rangeStats

results

smartIntervalHistogram

smartPercentileRanks

statistical

terms

termsDelta

termsStatsHits

terms_stats

text

twoLevelMatch

Keywords

FAQs

Package last updated on 03 Nov 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc