EsTractor: Simplified data extracton from Elasticsearch

home

rubygems.org/gems/es_tractor

dev

github.com/utilum/es_tractor/tree/dev

bugs

github.com/utilum/es_tractor/issues

rdoc

www.rubydoc.info/gems/es_tractor

DESCRIPTION:

es_tractor provides a reduced, simplified and more DRY search API to Elasticsearch. It aims to facilitate data extraction and preparation without server scripting.

FEATURES/PROBLEMS:

  • Subset of Search APIs: count, search, aggregations.

  • Supports most metrics aggregations without optional parameters.

  • Minimal DRY query builder maps root elements of a Hash argument into boolean filters and aggregations.

  • TODO:

    • Aggregations:

      • Bucket

      • Nesting

      • Optional parameters

    • Add Search APIs:

      • Fields

      • Sort

      • Scroll

    • Report formats: CSV, JSON.

    • Extraction: Aggregation to flat records (separate project?).

SYNOPSIS:

include EsTractor
tractor = Client.new

tractor.count
  # => (Integer) number of documents on the server

tractor.count(term: { my_field: 'my precise term' })
  # => (Integer) number of documents where my_field == 'my precise term'

tractor = Client.new true
tractor.search(size: 1, term: { my_field: 'my precise term' }) # => 
{
  "took"=>29,
  "timed_out"=>false,
  "_shards"=>{"total"=>542, "successful"=>542, "failed"=>0},
  "hits"=> {
    "total"=>279271,
    "max_score"=>0.0,
    "hits"=> [
      {
        "_index"=>"my_index",
        "_id"=>"bc596ff2-955b-11e7-a7d2-001ed3f963a9",
        "_score"=>0.0,
        "_source"=> {
          "my_field"=>"my precise term",
          "timestamp"=>"2017-09-09 12:38:09.263",
        },
      },
    ],
  },
}

REQUIREMENTS:

Some environment variables are expected:

  • ES_TRACTOR_ELASTICSEARCH_HOST

  • ES_TRACTOR_ELASTICSEARCH_INDEX

INSTALL:

$ gem install es_tractor

Or in your Gemfile:

gem 'es_tractor', '~> 0.0.3'

DEVELOPERS:

After checking out the source, run:

$ rake newb

This task will install any missing dependencies, run the tests, and generate the RDoc.

LICENSE:

(The MIT License)

Copyright © 2017 FIX

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.