GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - plotlabs/esgetfamily-node: Get parent and children documents from Elasticsearch using a single query.

BranchesTags
Open more actions menu

Latest commit

 

History

17 Commits
17 Commits

Folders and files

NameName
Last commit message
Last commit date
lib
lib
 
 
test
test
 
 
.gitignore
.gitignore
 
 
.travis.yml
.travis.yml
 
 
LICENSE.txt
LICENSE.txt
 
 
README.md
README.md
 
 
index.js
index.js
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 

Repository files navigation

Elasticsearch: Get Family - Node.js

GitHub license Build Status CodeFactor PRs Welcome npm

The following library helps you get a unified result with parents having result of children in a single result with scroll and custom query.

Installation

npm install esgetfamily --save
npm install esgetfamily

Using in node.js

var esgetfamily = require('esgetfamily');
esgetfamily(
  'http://localhost:9200',
  {
    index: 'es-getfamilytest',
    parent_type: 'parent',
    child_type: 'child'
  },
  [
    {
      _index: 'es-getfamilytest',
      _type: 'parent',
      _id: '1',
      _score: 1,
      _source: {
        id: 1,
        no_employee: 23,
        company: 'Plotlabs'
      }
    }
  ],
  [
    {
      match: {
        employee_name: 'employee 1'
      }
    }
  ],
  function(error, result) {
    // Do something here.
  }
);

Arguments

The function takes following arguments and in the following order

esgetfamily(
  < URL >,
  < connection parameters>,
  < data >,
  < filter >,
  function(error, result){
      // Do something here.
  }
);
  • URL: Mention the URL of either localhost or remote server
  • connection parameters: The argument has three parts { index: "name of the index", parent_type: "name of the parent type", children_type: "name of the children type" }
  • data: pass any data array of parent object/objects. '_id' in each object is essential for it to parse it's child
  • filter: you can pass any valid query object for eg. [{match: { "employee_name":"employee 1" }}]
  • callback: simple callback function with error as first argument

Result

The result are in the form:

[
  {
    "_index": "es-getfamilytest",
    "_type": "parent",
    "_id": "1",
    "_score": 1,
    "_source": { "id": 1, "no_employee": 23, "company": "Plotlabs" },
    "children": [
      {
        "_index": "es-getfamilytest",
        "_type": "child",
        "_id": "1",
        "_score": 1,
        "_routing": "1",
        "_parent": "1",
        "_source": { "id": 1, "name": "employee1" }
      }
    ]
  }
]

About

Get parent and children documents from Elasticsearch using a single query.

www.plotlabs.io

Topics

elasticsearchnodejsnpm-package

Resources

Readme
MIT license
Activity
Custom properties

Stars

8 stars

Watchers

3 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.