Showing preview only (1,790K chars total). Download the full file or copy to clipboard to get everything.
Repository: sudo-suhas/elastic-builder
Branch: master
Commit: 62463dd352f5
Files: 367
Total size: 1.6 MB
Directory structure:
gitextract_owzxfn2s/
├── .eslintignore
├── .eslintrc.yml
├── .gitattributes
├── .github/
│ └── workflows/
│ └── build.yml
├── .gitignore
├── .nvmrc
├── .prettierrc.json
├── .releaserc.json
├── .vscode/
│ ├── extensions.json
│ └── settings.json
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── deploy-docs.sh
├── docs/
│ ├── documentation.yml
│ ├── intro.md
│ └── publish.md
├── jsconfig.json
├── package.json
├── repl.js
├── roadmap.md
├── src/
│ ├── README.md
│ ├── _/
│ │ └── index.js
│ ├── aggregations/
│ │ ├── bucket-aggregations/
│ │ │ ├── adjacency-matrix-aggregation.js
│ │ │ ├── auto-date-histogram-aggregation.js
│ │ │ ├── bucket-aggregation-base.js
│ │ │ ├── children-aggregation.js
│ │ │ ├── composite-agg-values-sources/
│ │ │ │ ├── date-histogram-values-source.js
│ │ │ │ ├── histogram-values-source.js
│ │ │ │ ├── index.js
│ │ │ │ ├── terms-values-source.js
│ │ │ │ └── values-source-base.js
│ │ │ ├── composite-aggregation.js
│ │ │ ├── date-histogram-aggregation.js
│ │ │ ├── date-range-aggregation.js
│ │ │ ├── diversified-sampler-aggregation.js
│ │ │ ├── filter-aggregation.js
│ │ │ ├── filters-aggregation.js
│ │ │ ├── geo-distance-aggregation.js
│ │ │ ├── geo-hash-grid-aggregation.js
│ │ │ ├── geo-hex-grid-aggregation.js
│ │ │ ├── geo-tile-grid-aggregation.js
│ │ │ ├── global-aggregation.js
│ │ │ ├── histogram-aggregation-base.js
│ │ │ ├── histogram-aggregation.js
│ │ │ ├── index.js
│ │ │ ├── ip-range-aggregation.js
│ │ │ ├── missing-aggregation.js
│ │ │ ├── nested-aggregation.js
│ │ │ ├── parent-aggregation.js
│ │ │ ├── range-aggregation-base.js
│ │ │ ├── range-aggregation.js
│ │ │ ├── rare-terms-aggregation.js
│ │ │ ├── reverse-nested-aggregation.js
│ │ │ ├── sampler-aggregation.js
│ │ │ ├── significant-aggregation-base.js
│ │ │ ├── significant-terms-aggregation.js
│ │ │ ├── significant-text-aggregation.js
│ │ │ ├── terms-aggregation-base.js
│ │ │ ├── terms-aggregation.js
│ │ │ └── variable-width-histogram-aggregation.js
│ │ ├── index.js
│ │ ├── matrix-aggregations/
│ │ │ ├── index.js
│ │ │ └── matrix-stats-aggregation.js
│ │ ├── metrics-aggregations/
│ │ │ ├── avg-aggregation.js
│ │ │ ├── cardinality-aggregation.js
│ │ │ ├── extended-stats-aggregation.js
│ │ │ ├── geo-bounds-aggregation.js
│ │ │ ├── geo-centroid-aggregation.js
│ │ │ ├── index.js
│ │ │ ├── max-aggregation.js
│ │ │ ├── metrics-aggregation-base.js
│ │ │ ├── min-aggregation.js
│ │ │ ├── percentile-ranks-aggregation.js
│ │ │ ├── percentiles-aggregation.js
│ │ │ ├── scripted-metric-aggregation.js
│ │ │ ├── stats-aggregation.js
│ │ │ ├── sum-aggregation.js
│ │ │ ├── top-hits-aggregation.js
│ │ │ ├── value-count-aggregation.js
│ │ │ └── weighted-average-aggregation.js
│ │ └── pipeline-aggregations/
│ │ ├── avg-bucket-aggregation.js
│ │ ├── bucket-script-aggregation.js
│ │ ├── bucket-selector-aggregation.js
│ │ ├── bucket-sort-aggregation.js
│ │ ├── cumulative-sum-aggregation.js
│ │ ├── derivative-aggregation.js
│ │ ├── extended-stats-bucket-aggregation.js
│ │ ├── index.js
│ │ ├── max-bucket-aggregation.js
│ │ ├── min-bucket-aggregation.js
│ │ ├── moving-average-aggregation.js
│ │ ├── moving-function-aggregation.js
│ │ ├── percentiles-bucket-aggregation.js
│ │ ├── pipeline-aggregation-base.js
│ │ ├── serial-differencing-aggregation.js
│ │ ├── stats-bucket-aggregation.js
│ │ └── sum-bucket-aggregation.js
│ ├── core/
│ │ ├── aggregation.js
│ │ ├── consts.js
│ │ ├── geo-point.js
│ │ ├── geo-shape.js
│ │ ├── highlight.js
│ │ ├── index.js
│ │ ├── indexed-shape.js
│ │ ├── inner-hits.js
│ │ ├── inspect.js
│ │ ├── knn.js
│ │ ├── query.js
│ │ ├── request-body-search.js
│ │ ├── rescore.js
│ │ ├── runtime-field.js
│ │ ├── script.js
│ │ ├── search-template.js
│ │ ├── sort.js
│ │ ├── suggester.js
│ │ └── util.js
│ ├── index.d.ts
│ ├── index.js
│ ├── queries/
│ │ ├── compound-queries/
│ │ │ ├── bool-query.js
│ │ │ ├── boosting-query.js
│ │ │ ├── constant-score-query.js
│ │ │ ├── dis-max-query.js
│ │ │ ├── function-score-query.js
│ │ │ ├── index.js
│ │ │ └── score-functions/
│ │ │ ├── decay-score-function.js
│ │ │ ├── field-value-factor-function.js
│ │ │ ├── index.js
│ │ │ ├── random-score-function.js
│ │ │ ├── score-function.js
│ │ │ ├── script-score-function.js
│ │ │ └── weight-score-function.js
│ │ ├── full-text-queries/
│ │ │ ├── combined-fields-query.js
│ │ │ ├── common-terms-query.js
│ │ │ ├── full-text-query-base.js
│ │ │ ├── index.js
│ │ │ ├── match-phrase-prefix-query.js
│ │ │ ├── match-phrase-query-base.js
│ │ │ ├── match-phrase-query.js
│ │ │ ├── match-query.js
│ │ │ ├── mono-field-query-base.js
│ │ │ ├── multi-match-query.js
│ │ │ ├── query-string-query-base.js
│ │ │ ├── query-string-query.js
│ │ │ └── simple-query-string-query.js
│ │ ├── geo-queries/
│ │ │ ├── geo-bounding-box-query.js
│ │ │ ├── geo-distance-query.js
│ │ │ ├── geo-polygon-query.js
│ │ │ ├── geo-query-base.js
│ │ │ ├── geo-shape-query.js
│ │ │ └── index.js
│ │ ├── helper.js
│ │ ├── index.js
│ │ ├── joining-queries/
│ │ │ ├── has-child-query.js
│ │ │ ├── has-parent-query.js
│ │ │ ├── index.js
│ │ │ ├── joining-query-base.js
│ │ │ ├── nested-query.js
│ │ │ └── parent-id-query.js
│ │ ├── match-all-query.js
│ │ ├── match-none-query.js
│ │ ├── span-queries/
│ │ │ ├── index.js
│ │ │ ├── span-containing-query.js
│ │ │ ├── span-field-masking-query.js
│ │ │ ├── span-first-query.js
│ │ │ ├── span-little-big-query-base.js
│ │ │ ├── span-multi-term-query.js
│ │ │ ├── span-near-query.js
│ │ │ ├── span-not-query.js
│ │ │ ├── span-or-query.js
│ │ │ ├── span-query-base.js
│ │ │ ├── span-term-query.js
│ │ │ └── span-within-query.js
│ │ ├── specialized-queries/
│ │ │ ├── distance-feature-query.js
│ │ │ ├── index.js
│ │ │ ├── more-like-this-query.js
│ │ │ ├── percolate-query.js
│ │ │ ├── rank-feature-query.js
│ │ │ ├── script-query.js
│ │ │ └── script-score-query.js
│ │ ├── term-level-queries/
│ │ │ ├── exists-query.js
│ │ │ ├── fuzzy-query.js
│ │ │ ├── ids-query.js
│ │ │ ├── index.js
│ │ │ ├── multi-term-query-base.js
│ │ │ ├── prefix-query.js
│ │ │ ├── range-query.js
│ │ │ ├── regexp-query.js
│ │ │ ├── term-query.js
│ │ │ ├── terms-query.js
│ │ │ ├── terms-set-query.js
│ │ │ ├── type-query.js
│ │ │ ├── value-term-query-base.js
│ │ │ └── wildcard-query.js
│ │ └── vector-queries/
│ │ ├── index.js
│ │ ├── semantic-query.js
│ │ └── sparse-vector-query.js
│ ├── recipes.js
│ └── suggesters/
│ ├── analyzed-suggester-base.js
│ ├── completion-suggester.js
│ ├── direct-generator.js
│ ├── index.js
│ ├── phrase-suggester.js
│ └── term-suggester.js
├── test/
│ ├── .eslintrc.yml
│ ├── _/
│ │ └── index.test.js
│ ├── aggregations-test/
│ │ ├── adjacency-matrix-agg.test.js
│ │ ├── auto-date-histogram-agg.test.js
│ │ ├── avg-agg.test.js
│ │ ├── avg-bucket-agg.test.js
│ │ ├── bucket-agg-base.test.js
│ │ ├── bucket-script-agg.test.js
│ │ ├── bucket-selector-agg.test.js
│ │ ├── bucket-sort-agg.test.js
│ │ ├── cardinality-agg.test.js
│ │ ├── children-agg.test.js
│ │ ├── composite-agg-values-sources-test/
│ │ │ ├── date-histogram-values-source.test.js
│ │ │ ├── histogram-values-source.test.js
│ │ │ └── terms-values-source.test.js
│ │ ├── composite-agg.test.js
│ │ ├── cumulative-sum-agg.test.js
│ │ ├── date-histogram-agg.test.js
│ │ ├── date-range-agg.test.js
│ │ ├── derivative-agg.test.js
│ │ ├── diversified-sampler-agg.test.js
│ │ ├── extended-stats-agg.test.js
│ │ ├── extended-stats-bucket-agg.test.js
│ │ ├── filter-agg.test.js
│ │ ├── filters-agg.test.js
│ │ ├── geo-bounds-agg.test.js
│ │ ├── geo-centroid-agg.test.js
│ │ ├── geo-distance-agg.test.js
│ │ ├── geo-hash-grid-agg.test.js
│ │ ├── geo-hex-grid-agg.test.js
│ │ ├── geo-tile-grid-agg.test.js
│ │ ├── global-agg.test.js
│ │ ├── histogram-agg-base.test.js
│ │ ├── histogram-agg.test.js
│ │ ├── ip-range-agg.test.js
│ │ ├── matrix-stats-agg.test.js
│ │ ├── max-agg.test.js
│ │ ├── max-bucket-agg.test.js
│ │ ├── metrics-agg-base.test.js
│ │ ├── min-agg.test.js
│ │ ├── min-bucket-agg.test.js
│ │ ├── missing-agg.test.js
│ │ ├── moving-average-agg.test.js
│ │ ├── moving-function-agg.test.js
│ │ ├── nested-agg.test.js
│ │ ├── parent-agg.test.js
│ │ ├── percentile-ranks-agg.test.js
│ │ ├── percentiles-agg.test.js
│ │ ├── percentiles-bucket-agg.test.js
│ │ ├── pipeline-agg-base.test.js
│ │ ├── range-agg-base.test.js
│ │ ├── range-agg.test.js
│ │ ├── rare-terms-aggregation.test.js
│ │ ├── reverse-nested-agg.test.js
│ │ ├── sampler-agg.test.js
│ │ ├── scripted-metric-agg.test.js
│ │ ├── serial-differencing-agg.test.js
│ │ ├── significant-agg-base.test.js
│ │ ├── significant-terms-agg.test.js
│ │ ├── significant-text-agg.test.js
│ │ ├── stats-agg.test.js
│ │ ├── stats-bucket-agg.test.js
│ │ ├── sum-agg.test.js
│ │ ├── sum-bucket-agg.test.js
│ │ ├── terms-agg-base.test.js
│ │ ├── terms-agg.test.js
│ │ ├── top-hits-agg.test.js
│ │ ├── value-count-agg.test.js
│ │ ├── variable-width-histogram-aggregation.test.js
│ │ └── weighted-average-aggregation.test.js
│ ├── core-test/
│ │ ├── aggregation.test.js
│ │ ├── geo-point.test.js
│ │ ├── geo-shape.test.js
│ │ ├── highlight.test.js
│ │ ├── indexed-shape.test.js
│ │ ├── inner-hits.test.js
│ │ ├── knn.test.js
│ │ ├── query.test.js
│ │ ├── request-body-search.test.js
│ │ ├── rescore.test.js
│ │ ├── runtime-field.test.js
│ │ ├── script.test.js
│ │ ├── search-template.test.js
│ │ ├── sort.test.js
│ │ ├── suggester.test.js
│ │ └── util.test.js
│ ├── index.test.js
│ ├── queries-test/
│ │ ├── bool-query.test.js
│ │ ├── boosting-query.test.js
│ │ ├── combined-fields-query.test.js
│ │ ├── common-terms-query.test.js
│ │ ├── constant-score-query.test.js
│ │ ├── decay-score-func.test.js
│ │ ├── dis-max-query.test.js
│ │ ├── distance-feature.test.js
│ │ ├── exists-query.test.js
│ │ ├── field-value-factor-func.test.js
│ │ ├── full-text-query-base.test.js
│ │ ├── function-score-query.test.js
│ │ ├── fuzzy-query.test.js
│ │ ├── geo-bounding-box-query.test.js
│ │ ├── geo-distance-query.test.js
│ │ ├── geo-polygon-query.test.js
│ │ ├── geo-query-base.test.js
│ │ ├── geo-shape-query.test.js
│ │ ├── has-child-query.test.js
│ │ ├── has-parent-query.test.js
│ │ ├── ids-query.test.js
│ │ ├── joining-query-base.test.js
│ │ ├── match-all-query.test.js
│ │ ├── match-none-query.test.js
│ │ ├── match-phrase-prefix-query.test.js
│ │ ├── match-phrase-query-base.test.js
│ │ ├── match-phrase-query.test.js
│ │ ├── match-query.test.js
│ │ ├── mono-field-query-base.test.js
│ │ ├── more-like-this-query.test.js
│ │ ├── multi-match-query.test.js
│ │ ├── nested-query.test.js
│ │ ├── parent-id-query.test.js
│ │ ├── percolate-query.test.js
│ │ ├── prefix-query.test.js
│ │ ├── query-string-query-base.test.js
│ │ ├── query-string-query.test.js
│ │ ├── random-score-func.test.js
│ │ ├── range-query.test.js
│ │ ├── rank-feature.test.js
│ │ ├── regexp-query.test.js
│ │ ├── score-func.test.js
│ │ ├── script-query.test.js
│ │ ├── script-score-func.test.js
│ │ ├── script-score-query.test.js
│ │ ├── semantic-query.test.js
│ │ ├── simple-query-string-query.test.js
│ │ ├── span-containing-query.test.js
│ │ ├── span-field-masking-query.test.js
│ │ ├── span-first-query.test.js
│ │ ├── span-little-big-query-base.test.js
│ │ ├── span-multi-term-query.test.js
│ │ ├── span-near-query.test.js
│ │ ├── span-not-query.test.js
│ │ ├── span-or-query.test.js
│ │ ├── span-term-query.test.js
│ │ ├── span-within-query.test.js
│ │ ├── sparse-vector-query.test.js
│ │ ├── term-query.test.js
│ │ ├── terms-query.test.js
│ │ ├── terms-set-query.test.js
│ │ ├── type-query.test.js
│ │ ├── weight-score-func.test.js
│ │ └── wildcard-query.test.js
│ ├── recipes.test.js
│ ├── suggesters-test/
│ │ ├── analyzed-suggester-base.test.js
│ │ ├── completion-suggester.test.js
│ │ ├── direct-generator.test.js
│ │ ├── phrase-suggester.test.js
│ │ └── term-suggester.test.js
│ ├── testing-guidelines.mdc
│ ├── testutil/
│ │ └── index.js
│ └── typedef.test.ts
├── vitest.config.js
└── webpack.config.js
================================================
FILE CONTENTS
================================================
================================================
FILE: .eslintignore
================================================
browser
docs
lib
_build
================================================
FILE: .eslintrc.yml
================================================
root: true
parser: '@babel/eslint-parser'
parserOptions:
ecmaVersion: 2020
sourceType: module
requireConfigFile: false
env:
node: true
es6: true
extends:
- 'eslint:recommended'
- 'plugin:prettier/recommended'
plugins:
- prettier
rules:
id-length: off
class-methods-use-this:
- error
- exceptMethods:
# These methods are often overridden to hide implementation
# in parent class and throw error on invokation.
- field
- script
- missing
- format
- gapPolicy
- validationMethod
- scoreMode
- value
- executionHint
- _warn
no-unused-vars:
- error
- argsIgnorePattern: '^_'
no-console: off
prefer-const: error
no-var: error
no-irregular-whitespace:
- error
- skipComments: true
================================================
FILE: .gitattributes
================================================
* text=auto
*.js text eol=lf
*.sh text eol=lf
================================================
FILE: .github/workflows/build.yml
================================================
name: build
on:
push:
tags: [v*]
branches: [master]
pull_request:
permissions:
id-token: write # to enable use of OIDC for trusted publishing and npm provenance
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests
jobs:
check:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x, 22.x, 24.x]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Check
run: npm run check
- name: Coveralls
uses: coverallsapp/github-action@1.1.3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: ${{matrix.os}}-node-${{ matrix.node }}
parallel: true
finish:
needs: check
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@1.1.3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
release:
needs: check
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '24.x'
registry-url: 'https://registry.npmjs.org'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release@25
================================================
FILE: .gitignore
================================================
# Logs
logs
*.log
npm-debug.log*
# Runtime data
pids
*.pid
*.seed
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# node-waf configuration
.lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules
jspm_packages
# Optional npm cache directory
.npm
# Optional REPL history
.node_repl_history
# local test files
experiment.js
# babel generated files
lib
# files generated for tests(pre compilation)
_build
# generated docs
browser/
docs/assets/
docs/index.html
# ides
.idea
================================================
FILE: .nvmrc
================================================
24
================================================
FILE: .prettierrc.json
================================================
{
"tabWidth": 4,
"semi": true,
"singleQuote": true,
"trailingComma": "none",
"proseWrap": "preserve",
"arrowParens": "avoid",
"printWidth": 80,
"overrides": [
{
"files": "*.md",
"options": {
"tabWidth": 2,
"proseWrap": "always"
}
},
{
"files": "*.json",
"options": {
"tabWidth": 2
}
}
]
}
================================================
FILE: .releaserc.json
================================================
{
"branches": [
"master",
"next"
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
[
"@semantic-release/npm",
{
"npmPublish": true,
"pkgRoot": "."
}
],
"@semantic-release/github"
]
}
================================================
FILE: .vscode/extensions.json
================================================
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
"dbaeumer.vscode-eslint",
"HookyQR.beautify",
"eg2.vscode-npm-script",
"dkundel.vscode-npm-source",
"esbenp.prettier-vscode"
]
}
================================================
FILE: .vscode/settings.json
================================================
// Place your settings in this file to overwrite default and user settings.
{
"eslint.enable": true,
"files.eol": "\n",
"vsicons.presets.angular": false,
"editor.detectIndentation": true,
"[json]": {
"editor.tabSize": 2
},
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
}
}
================================================
FILE: CODE_OF_CONDUCT.md
================================================
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at sudo.suhas@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
================================================
FILE: CONTRIBUTING.md
================================================
# Contributing
Thank you for taking the time to contribute to elastic-builder! Your work is truly
appreciated.
Please follow this guide to make that PR the best that it can be!
## Guidelines
* Write small commits with concise, descriptive messages.
* Include tests for any new feature, and regression tests for any bug fix.
* Write [es2015+ javascript][1].
* Try to keep the code style consistent. Follow existing patterns.
* Modify or add to the README if your feature needs instructions on how to use it.
## Development
Fork, then clone the repo:
```
git clone https://github.com/your-username/elastic-builder.git
```
Install dependencies using npm.
```
npm install
```
### Write code
Typically, your changes will go in the `src` directory (the `lib` directory
contains transpiled babel code) and the `test` directory.
No need to generate the built files, these will be added when a new version of
elastic-builder is published to npm.
### Run tests
This project uses eslint for javascript linting and vitest for testing. Run
linting using `npm run lint` and run tests using `npm test`. Or run both using:
```
npm run check
```
This should take care of formatting as well thanks to [eslint-plugin-prettier][3].
You can also run tests in watch mode during development:
```
npm run test:watch
```
To generate coverage reports:
```
npm run test:src
```
Coverage reports are generated in the `coverage/` directory.
### (Optional) Add yourself as a contributor
Thanks for contributing! Go ahead and add yourself to the list of contributors
in the npm package manifest `package.json`.
### Submit your PR
This is the last step! Make sure your PR is aimed to merge with the `master`
branch.
You should also write a good PR message with information on why this feature or
fix is necesary or a good idea. For features, be sure to include information on
how to use the feature; and for bugs, information on how to reproduce the bug is
helpful!
## Need help?
If you have any questions about the feature or fix you want to make, or if you
have doubts about the approach, or anything else you're not sure about, the best
way to get in touch is to [open an issue][4]. I am happy to help out.
[1]: https://babeljs.io/docs/learn-es2015/
[2]: https://nodejs.org/
[3]: https://github.com/not-an-aardvark/eslint-plugin-prettier
[4]: https://github.com/sudo-suhas/elastic-builder/issues/new
================================================
FILE: LICENSE
================================================
MIT License
Copyright (c) 2017 Suhas Karanth
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.
================================================
FILE: README.md
================================================
# elastic-builder
[![npm version][version-badge]][package] [![Build Status][build-badge]][build]
[![Coverage Status][coverage-badge]][coverage]
[![semantic-release][semantic-release-badge]][semantic-release]
A Node.js implementation of the [Elasticsearch][elasticsearch] DSL for use with
the [official elasticsearch javascript client][es-js-client] with builder
syntax.

**Check out the [API reference documentation][api-docs].**
Relevant blog post:
https://blog.logrocket.com/elasticsearch-query-body-builder-node-js/
elastic-builder includes TypeScript definition for superior development
experience.
## Node.js Requirements
`elastic-builder` supports Node.js **20.x**, **22.x**, and **24.x** (LTS versions).
## Elasticsearch compatibility
`elastic-builder` was built for 5.x query DSL. However, the library should be
usable with 2.x as well. For older versions of the DSL, you can try
[`elastic.js`][elastic-js-fork] or [`bodybuilder`][bodybuilder]
`elastic-builder` is also compatible with elasticsearch 6.0(alpha) for the most
part. However, there are some [breaking changes][es-6-breaking-changes] which
have been called out in the docs(ex: [`Script.file`][api-docs-script-file].
What's Included:
- [Request Body Search][es-search-request-body]
- [Queries][es-query-dsl]
- [Aggregations][es-search-aggregations]
- [Suggesters][es-search-suggesters]
- [Search Template][es-search-template.html]
## Install
```
npm install elastic-builder --save
```
## Usage
```js
const esb = require('elastic-builder'); // the builder
const requestBody = esb.requestBodySearch()
.query(esb.matchQuery('message', 'this is a test'));
// OR
const requestBody = new esb.RequestBodySearch().query(
new esb.MatchQuery('message', 'this is a test')
);
requestBody.toJSON(); // or print to console - esb.prettyPrint(requestBody)
{
"query": {
"match": {
"message": "this is a test"
}
}
}
```
For each class, `MyClass`, a utility function `myClass` has been provided which
constructs the object for us without the need for `new` keyword.
## REPL
Try it out on the command line using the node REPL:
```
# Start the repl
node ./node_modules/elastic-builder/repl.js
# The builder is available in the context variable esb
elastic-builder > esb.prettyPrint(
... esb.requestBodySearch()
... .query(esb.matchQuery('message', 'this is a test'))
... );
{
"query": {
"match": {
"message": "this is a test"
}
}
}
```
## Motivation
Elasticsearch only provides a low level client for making requests.
[`elastic.js`][elastic-js] was a relatively popular library for building the
request search body. However, this project is not being maintained nor is the
[fork][elastic-js-fork]. There were [several changes][es-5-breaking-changes] in
the 5.0 release which make the older libraries unusable.
This library is a port of `elastic.js` to es6 with elasticsearch 5.x
compatibility.
## API Reference
API reference can be accessed here - https://elastic-builder.js.org/docs. The
docs include examples ported from the [official elasticsearch
reference][es-reference].
API documentation was generated using [documentation.js][documentation-js]. It
is being hosted with help from this awesome project -
https://github.com/js-org/dns.js.org
## Recipes
The library has a few helper recipes:
- [Missing query][es-missing-query]
- [Random sort query][es-random-score-query]
- [Filter query][es-filter-query]
```js
const qry = esb.cookMissingQuery('user');
qry.toJSON();
{
"bool": {
"must_not": {
"exists": { "field": "user" }
}
}
}
```
Check out the [reference docs][api-docs-recipes] for more examples.
If you have any recipes, please do share or better yet, create a [pull
request][create-pull-request] :smile:.
## Changelog
[releases][releases]
## Examples
**Usage with official elasticsearch client:**
```js
'use strict';
const elasticsearch = require('elasticsearch');
const esb = require('elastic-builder');
const client = new elasticsearch.Client({
host: 'localhost:9200',
log: 'trace'
});
const requestBody = esb
.requestBodySearch()
.query(esb.matchQuery('body', 'elasticsearch'));
client
.search({
index: 'twitter',
type: 'tweets',
body: requestBody.toJSON()
})
.then(resp => {
const hits = resp.hits.hits;
})
.catch(err => {
console.trace(err.message);
});
```
```js
// Bool query
const requestBody = esb.requestBodySearch().query(
esb.boolQuery()
.must(esb.matchQuery('last_name', 'smith'))
.filter(esb.rangeQuery('age').gt(30))
);
requestBody.toJSON();
{
"query": {
"bool": {
"must": {
"match": { "last_name": "smith" }
},
"filter": {
"range": { "age": { "gt": 30 } }
}
}
}
}
// Multi Match Query
const requestBody = esb.requestBodySearch().query(
esb.multiMatchQuery(['title', 'body'], 'Quick brown fox')
.type('best_fields')
.tieBreaker(0.3)
.minimumShouldMatch('30%')
);
requestBody.toJSON();
{
"multi_match": {
"query": "Quick brown fox",
"type": "best_fields",
"fields": ["title", "body"],
"tie_breaker": 0.3,
"minimum_should_match": "30%"
}
}
// Aggregation
const requestBody = esb.requestBodySearch()
.size(0)
.agg(esb.termsAggregation('popular_colors', 'color'));
requestBody.toJSON();
{
"size": 0,
"aggs": {
"popular_colors": {
"terms": { "field": "color" }
}
}
}
// Nested Aggregation
const requestBody = esb.requestBodySearch()
.size(0)
.agg(
esb.termsAggregation('colors', 'color')
.agg(esb.avgAggregation('avg_price', 'price'))
.agg(esb.termsAggregation('make', 'make'))
);
requestBody.toJSON();
{
"size": 0,
"aggs": {
"colors": {
"terms": { "field": "color" },
"aggs": {
"avg_price": {
"avg": { "field": "price" }
},
"make": {
"terms": { "field": "make" }
}
}
}
}
}
// If you prefer using the `new` keyword
const agg = new esb.TermsAggregation('countries', 'artist.country')
.order('rock>playback_stats.avg', 'desc')
.agg(
new esb.FilterAggregation('rock', new esb.TermQuery('genre', 'rock')).agg(
new esb.StatsAggregation('playback_stats', 'play_count')
)
);
agg.toJSON();
{
"countries": {
"terms": {
"field": "artist.country",
"order": { "rock>playback_stats.avg": "desc" }
},
"aggs": {
"rock": {
"filter": {
"term": { "genre": "rock" }
},
"aggs": {
"playback_stats": {
"stats": { "field": "play_count" }
}
}
}
}
}
}
// Sort
const requestBody = esb.requestBodySearch()
.query(esb.boolQuery().filter(esb.termQuery('message', 'test')))
.sort(esb.sort('timestamp', 'desc'))
.sorts([
esb.sort('channel', 'desc'),
esb.sort('categories', 'desc'),
// The order defaults to desc when sorting on the _score,
// and defaults to asc when sorting on anything else.
esb.sort('content'),
esb.sort('price').order('desc').mode('avg')
]);
requestBody.toJSON();
{
"query": {
"bool": {
"filter": {
"term": { "message": "test" }
}
}
},
"sort": [
{ "timestamp": { "order": "desc" } },
{ "channel": { "order": "desc" } },
{ "categories": { "order": "desc" } },
"content",
{ "price": { "order": "desc", "mode": "avg" } }
]
}
// From / size
const requestBody = esb.requestBodySearch()
.query(esb.matchAllQuery())
.size(5)
.from(10);
requestBody.toJSON();
{
"query": { "match_all": {} },
"size": 5,
"from": 10
}
```
For more examples, check out the [reference docs][api-docs].
## Validation
`elastic-builder` provides lightweight validation where ever possible:
```
$ node ./node_modules/elastic-builder/repl.js
elastic-builder > esb.multiMatchQuery().field('title').field('body').query('Quick brown fox').type('bwst_fields')
See https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html
Got 'type' - bwst_fields
Error: The 'type' parameter should belong to Set {
'best_fields',
'most_fields',
'cross_fields',
'phrase',
'phrase_prefix' }
at MultiMatchQuery.type (E:\Projects\repos\elastic-builder\lib\queries\full-text-queries\multi-match-query.js:134:23)
at repl:1:77
at ContextifyScript.Script.runInContext (vm.js:35:29)
at REPLServer.defaultEval (repl.js:342:29)
at bound (domain.js:280:14)
at REPLServer.runBound [as eval] (domain.js:293:12)
at REPLServer.<anonymous> (repl.js:538:10)
at emitOne (events.js:96:13)
at REPLServer.emit (events.js:188:7)
at REPLServer.Interface._onLine (readline.js:239:10)
```
## Tests
Run unit tests:
```
npm test
```
Run tests in watch mode:
```
npm run test:watch
```
Run tests with coverage:
```
npm run test:src
```
Coverage reports are generated in the `coverage/` directory.
## Credits
`elastic-builder` is heavily inspired by [`elastic.js`][elastic-js] and the
[fork][elastic-js-fork] by Erwan Pigneul.
[`bodybuilder`][bodybuilder] for documentation style, build setup, demo page.
## License
MIT © [Suhas Karanth][sudo-suhas]
[version-badge]: https://badge.fury.io/js/elastic-builder.svg
[package]: https://www.npmjs.com/package/elastic-builder
[build-badge]:
https://github.com/sudo-suhas/elastic-builder/actions/workflows/build.yml/badge.svg
[build]: https://github.com/sudo-suhas/elastic-builder/actions/workflows/build.yml
[coverage-badge]:
https://coveralls.io/repos/github/sudo-suhas/elastic-builder/badge.svg?branch=master
[coverage]: https://coveralls.io/github/sudo-suhas/elastic-builder?branch=master
[semantic-release-badge]:
https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg
[semantic-release]: https://github.com/semantic-release/semantic-release
[elasticsearch]: https://www.elasticsearch.org/
[es-js-client]:
https://www.elasticsearch.org/guide/en/elasticsearch/client/javascript-api/current/index.html
[es-reference]:
https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html
[es-5-breaking-changes]:
https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking_50_search_changes.html
[es-6-breaking-changes]:
https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking_60_search_changes.html
[es-search-request-body]:
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html
[es-query-dsl]:
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html
[es-missing-query]:
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-exists-query.html#_literal_missing_literal_query
[es-random-score-query]:
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html#function-random
[es-filter-query]:
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html
[es-search-aggregations]:
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations.html
[es-search-suggesters]:
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters.html
[es-search-template.html]:
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html
[api-docs]: https://elastic-builder.js.org/docs
[api-docs-recipes]: https://elastic-builder.js.org/docs#recipes
[api-docs-script-file]: https://elastic-builder.js.org/docs/#scriptfile
[releases]: https://github.com/sudo-suhas/elastic-builder/releases
[elastic-js]: https://github.com/fullscale/elastic.js
[elastic-js-fork]: https://github.com/ErwanPigneul/elastic.js
[bodybuilder]: https://github.com/danpaz/bodybuilder
[documentation-js]: https://github.com/documentationjs/documentation
[create-pull-request]:
https://help.github.com/articles/creating-a-pull-request-from-a-fork/
[sudo-suhas]: https://github.com/sudo-suhas
================================================
FILE: deploy-docs.sh
================================================
#!/bin/bash -xe
# See http://tldp.org/LDP/abs/html/options.html
# -x -> Print each command to stdout before executing it, expand commands
# -e -> Abort script at first error, when a command exits with non-zero status
# (except in until or while loops, if-tests, list constructs)
if ! hash gh-pages 2> /dev/null; then
npm i -g gh-pages
fi
gh-pages --add \
--dist . \
--src "{browser/*,docs/*}" \
--repo "https://git:${GITHUB_TOKEN}@github.com/sudo-suhas/elastic-builder.git" \
--message "docs: Build docs for $(npm run -s print-version)" \
--user "github-actions-bot <support+actions@github.com>"
================================================
FILE: docs/documentation.yml
================================================
toc:
- name: elastic-builder
file: intro.md
- RequestBodySearch
- name: Queries
description: |
These classes allow creation and manipulation of objects which map to
elasticsearch DSL for queries.
- Query
- MatchAllQuery
- MatchNoneQuery
- name: Full Text Queries
- FullTextQueryBase
- MonoFieldQueryBase
- MatchQuery
- MatchPhraseQueryBase
- MatchPhraseQuery
- MatchPhrasePrefixQuery
- MultiMatchQuery
- CommonTermsQuery
- QueryStringQueryBase
- QueryStringQuery
- SimpleQueryStringQuery
- name: Term Level Queries
- ValueTermQueryBase
- TermQuery
- TermsQuery
- TermsSetQuery
- MultiTermQueryBase
- RangeQuery
- ExistsQuery
- PrefixQuery
- WildcardQuery
- RegexpQuery
- FuzzyQuery
- TypeQuery
- IdsQuery
- name: Compound Queries
- ConstantScoreQuery
- BoolQuery
- DisMaxQuery
- FunctionScoreQuery
- BoostingQuery
- name: Joining Queries
- JoiningQueryBase
- NestedQuery
- HasChildQuery
- HasParentQuery
- ParentIdQuery
- name: Geo Queries
- GeoQueryBase
- GeoShapeQuery
- GeoBoundingBoxQuery
- GeoDistanceQuery
- GeoPolygonQuery
- name: Specialized Queries
- MoreLikeThisQuery
- ScriptQuery
- PercolateQuery
- name: Span Queries
- SpanQueryBase
- SpanTermQuery
- SpanMultiTermQuery
- SpanFirstQuery
- SpanNearQuery
- SpanOrQuery
- SpanNotQuery
- SpanLittleBigQueryBase
- SpanContainingQuery
- SpanWithinQuery
- SpanFieldMaskingQuery
- name: Aggregations
description: |
These classes can be used to leverage the aggregations framework which helps provide
aggregated data based on a search query. They can be composed together with queries
and other aggregations in order to build complex summaries of the data.
- Aggregation
- name: Metrics Aggregations
- MetricsAggregationBase
- AvgAggregation
- CardinalityAggregation
- ExtendedStatsAggregation
- GeoBoundsAggregation
- GeoCentroidAggregation
- MaxAggregation
- MinAggregation
- PercentilesAggregation
- PercentileRanksAggregation
- ScriptedMetricAggregation
- StatsAggregation
- SumAggregation
- TopHitsAggregation
- ValueCountAggregation
- name: Bucket Aggregations
- BucketAggregationBase
- AdjacencyMatrixAggregation
- AutoDateHistogramAggregation
- ChildrenAggregation
- CompositeAggregation
- name: Values Source
description: |
The sources parameter controls the sources that should be used to build
the composite buckets. There are three different types of values source:
- [`Terms`](#termsvaluessource)
- [`Histogram`](#histogramvaluessource)
- [`Date Histogram`](#datehistogramvaluessource)
- ValuesSourceBase
- TermsValuesSource
- HistogramValuesSource
- DateHistogramValuesSource
- HistogramAggregationBase
- DateHistogramAggregation
- RangeAggregationBase
- DateRangeAggregation
- DiversifiedSamplerAggregation
- FilterAggregation
- FiltersAggregation
- GeoDistanceAggregation
- GeoHashGridAggregation
- GlobalAggregation
- HistogramAggregation
- IpRangeAggregation
- MissingAggregation
- NestedAggregation
- ParentAggregation
- RangeAggregation
- RareTermsAggregation
- ReverseNestedAggregation
- SamplerAggregation
- TermsAggregationBase
- SignificantAggregationBase
- SignificantTermsAggregation
- SignificantTextAggregation
- TermsAggregation
- name: Pipeline Aggregations
- PipelineAggregationBase
- AvgBucketAggregation
- DerivativeAggregation
- MaxBucketAggregation
- MinBucketAggregation
- SumBucketAggregation
- StatsBucketAggregation
- ExtendedStatsBucketAggregation
- PercentilesBucketAggregation
- MovingAverageAggregation
- MovingFunctionAggregation
- CumulativeSumAggregation
- BucketScriptAggregation
- BucketSelectorAggregation
- SerialDifferencingAggregation
- BucketSortAggregation
- name: Matrix Aggregations
- MatrixStatsAggregation
- name: Score Functions
- ScoreFunction
- ScriptScoreFunction
- WeightScoreFunction
- RandomScoreFunction
- FieldValueFactorFunction
- DecayScoreFunction
- name: Suggesters
- Suggester
- AnalyzedSuggesterBase
- TermSuggester
- DirectGenerator
- PhraseSuggester
- CompletionSuggester
- name: Miscellaneous
- Highlight
- Script
- GeoPoint
- GeoShape
- IndexedShape
- Sort
- Rescore
- InnerHits
- SearchTemplate
================================================
FILE: docs/intro.md
================================================
https://github.com/sudo-suhas/elastic-builder
`elastic-builder` is a library for easily building elasticsearch request body for search.
It implements the builder syntax for building complex queries combining queries and aggregations.
What's Included:
* [Request Body Search](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html)
* [Queries](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html)
* [Aggregations](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations.html)
* [Suggesters](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters.html)
* [Search Template](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html)
The complete library documentation is present here.
There are two ways to use the classes for constructing queries:
```js
// Import the library
const esb = require('elastic-builder'); // the builder
// Use `new` keyword for constructor instances of class
const requestBody = new esb.RequestBodySearch()
.query(new esb.MatchQuery('message', 'this is a test'));
// Or use helper methods which construct the object without need for the `new` keyword
const requestBody = esb.requestBodySearch()
.query(esb.matchQuery('message', 'this is a test'));
// Build the request body
requestBody.toJSON()
{
"query": {
"match": {
"message": "this is a test"
}
}
}
```
**Demo** - https://elastic-builder.js.org/
**ProTip:** The source is transpiled using babel for compatibility with older versions of node and used by default.
But this is not required in node env 6 and above. You can directly use the `src` files:
```js
const esb = require('elastic-builder/src');
```
This module is heavily influenced by [elastic.js](https://github.com/fullscale/elastic.js)(not maintained anymore).
================================================
FILE: docs/publish.md
================================================
# Publish to npm
This is primarily a reference for how to publish a new version of this package
to npm. Currently, @sudo-suhas is the only one doing this.
1. Ensure master branch is up to date `git checkout master && git pull && git status`.
2. Ensure logged in as the expected npm user `npm whoami`.
4. Bump the npm version `npm version major|minor|patch`. This will also:
- Run ~tests~ and style checks locally.
- Generate built files.
- Commit built files to master branch.
- Generate a tagged version commit.
- Push to GitHub and ~trigger a Travis build~.
- ~Travis CI should automatically publish to npm~.
================================================
FILE: jsconfig.json
================================================
{
// See https://go.microsoft.com/fwlink/?LinkId=759670
// for the documentation about the jsconfig.json format
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"allowSyntheticDefaultImports": true,
"sourceMap": true
},
"exclude": [
"node_modules",
"bower_components",
"jspm_packages",
"tmp",
"temp"
]
}
================================================
FILE: package.json
================================================
{
"name": "elastic-builder",
"version": "0.0.0-development",
"description": "A JavaScript implementation of the elasticsearch Query DSL",
"main": "src/index.js",
"files": [
"src/",
"repl.js",
"index.d.ts"
],
"types": "./src/index.d.ts",
"scripts": {
"build:umd": "webpack ./src/index.js --output-path browser --output-filename elastic-builder.min.js --mode production",
"build:docs": "documentation build src/index.js --github -o docs -f html -c ./docs/documentation.yml",
"build": "npm run build:umd && npm run build:docs",
"lint": "eslint src test",
"lint:fix": "npm run lint -- --fix",
"precommit": "lint-staged",
"test:src": "vitest run --coverage",
"test:typedef": "tsc --noEmit ./test/typedef.test.ts",
"test": "npm run test:src && npm run test:typedef",
"test:watch": "vitest",
"check": "npm run lint && npm test",
"print-version": "cross-env-shell echo v$npm_package_version",
"prepublishOnly": "npm run -s build",
"postpublish": "bash deploy-docs.sh"
},
"license": "MIT",
"engines": {
"node": ">=20.0.0"
},
"devDependencies": {
"@babel/cli": "^7.25.9",
"@babel/core": "^7.25.9",
"@babel/eslint-parser": "^7.25.9",
"@babel/plugin-transform-runtime": "^7.25.9",
"@babel/preset-env": "^7.25.9",
"@vitest/coverage-v8": "^2.1.8",
"babel-loader": "^10.0.0",
"cross-env": "^7.0.3",
"documentation": "^8.0.0",
"eslint": "^8.57.1",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-vitest": "^0.5.4",
"husky": "^0.14.3",
"lint-staged": "^7.2.0",
"lodash": "^4.17.21",
"prettier": "^3.4.2",
"sinon": "^17.0.2",
"terser-webpack-plugin": "^5.3.14",
"typescript": "^5.9.2",
"vitest": "^2.1.8",
"webpack": "^5.101.2",
"webpack-cli": "^6.0.1"
},
"lint-staged": {
"src/**/*.js": [
"eslint --fix",
"git add"
],
"test/**/*.js": [
"eslint --fix",
"git add"
]
},
"homepage": "https://elastic-builder.js.org",
"repository": {
"type": "git",
"url": "https://github.com/sudo-suhas/elastic-builder.git"
},
"bugs": {
"url": "https://github.com/sudo-suhas/elastic-builder/issues"
},
"keywords": [
"elasticsearch",
"elastic-builder",
"querying",
"queries",
"query",
"elastic",
"search",
"elasticjs",
"ejs",
"dsl"
],
"author": "Suhas Karanth <sudo.suhas@gmail.com>",
"contributors": [
"austin ce <austin.cawley@gmail.com>",
"Julien Maitrehenry <julien.maitrehenry@me.com>",
"ochan12 <mateochando@gmail.com>",
"kennylindahl <haxxblaster@gmail.com>",
"foxstarius <aj.franzon@gmail.com>",
"sandeep952 <sandy335582@gmail.com>",
"florian-lackner365 <florian.lackner@365talents.com>",
"Alejandro Marulanda <alejokf@gmail.com>"
]
}
================================================
FILE: repl.js
================================================
'use strict';
const repl = require('repl');
const esb = require('./lib');
repl.start('elastic-builder > ').context.esb = esb;
================================================
FILE: roadmap.md
================================================
# Roadmap
- [x] Setup github pages, add CNAME
- [x] Improve README
+ [x] Usage
+ [x] Examples
+ [x] Credits
- [x] Host documentation, demo using js.org
- [x] Tests
- [x] travis setup with npm publish
- [x] Elasticsearch docs pull request
- [x] Documentation examples
- [x] Add an `index.d.ts` file for better intellisense - http://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html, https://github.com/Microsoft/TypeScript/issues/8335
- [x] Add Adjacency matrix Aggregation to Bucket Aggregations
- [x] Suggesters
- [ ] Use ES6 modules
================================================
FILE: src/README.md
================================================
# Source Guide
All good open source repositories have an excellent README guide or a website which
explains how to _use_ it. But most of them don't have any kind of guide for the source itself.
Although this is less likely to be useful for the average user, it can be quite useful for
anyone who is looking to contribute or perhaps wants to debug a weird behavior.
You absolutely don't _need_ to read this. But you could. If you wanted to.
## Project structure overview
All the source files written in ES6 are present in the `src` folder.
```js
// package.json snippet
{
// ...
// Files to be picked up by npm
"files": [
"browser/",
"src/",
"repl.js",
"index.d.ts"
],
// ...
}
```
These files are then packed into a minified `umd` module
for use in the browser and kept in the `browser` folder.
This is also used by the demo hosted on https://elastic-builder.js.org
The code in `src` folder doesn't use es6 imports. So it can be directly used without the transpiled code.
Earlier, the transpiled code used to jumble the documentation so there was an advantage to using
from `elastic-builder/src`. But now I have added the type definition so that advantage no longer applies.
Starting from the base folder `src`, `index.js` simply pulls in all the concrete classes and re-exports
them under the same object so that you can access all queries and aggregations. It also adds
helper methods so that the class, for example `MatchQuery` can be instantiated with `esb.matchQuery()`
thereby avoiding the `new` keyword. This means there are 2 ways of doing the same thing. While this is not ideal,
the reason for doing so because the documentation, type definitions declare classes and
it might be confusing to access them using only functions. I am open to rethinking this approach.
`recipes.js` has a few helper methods for augmenting the base queries and aggregations.
For example, although elasticsearch no longer supports the `missing` query, there is a helper recipe for that.
I am also considering adding a `bodybuilder` style bool query builder to the recipes.
The library uses inheritance and es6 class syntax quite heavily. The base classes for
request body search, queries, aggregations and other misc classes are present in `core`.
The queries, aggregations are organised to mirror the elasticsearch reference guide.
Whereever there is common behavior for multiple classes, the methods are moved to a base class.
Strictly speaking, all the base classes are instantiable.
But this is less likely to be useful and hence are not exported.
You could very easily override or extend any behavior for these classes.
Some classes have a relatively long inheritance chain.
```
Query -> FullTextQueryBase -> MonoFieldQueryBase -> MatchPhraseQueryBase -> MatchPhraseQuery
```
This can get a little confusing but I am hoping that the type definition solves
most of the woes.
Tests are written using `ava` and each file is independent. I am using macros heavily.
Probably harder to understand. But very good for reusing test code.
To be able to test with different node versions,
we need to use `babel` again. However, the `lib` files do not have source maps(not useful in prod) so cannot be used
to measure coverage. Earlier, I setup `ava` to use `babel-register` but with the sheer number of files,
this performed very poorly. So as suggested in a `ava` recipe, I setup pre-compilation step to transpile
tests to `_build` folder(not tracked in git).
You can pretty much ignore the `assets` folder.
## Release
I am using `release-it` for making releases. One of the key factors for doing this is to
auto generate release notes. I also looked into conventional changelog and am trying to follow that
for commits. On starting the release, it runs tests, builds `lib`, generates documentation(`docs` folder)
and creates the github release. I manually wait for all tests in travis to pass before running `npm publish`.
There are other options like semantic release which can take care of the entire workflow but
provide less flexibility. I am not yet completely comfortable with git branches and am using the `master`
branch itself for pushing commits. So I don't _always_ want to release when I push to master.
## Dependencies
For the project prod dependencies, I am using the modularised `lodash` libraries
along with `babel-runtime`. The reason for doing this, although quite unlikely,
is because if someone does use it, they shouldn't have to load 100 kb worth of `lodash`.
There are plugins available for only exporting what you use but the end user may not be aware of that.
================================================
FILE: src/_/index.js
================================================
'use strict';
/**
* Checks if value is null or undefined.
*
* @param {*} value The value to check.
* @returns {boolean} Returns true if value is null or undefined, else false.
*/
exports.isNil = function isNil(value) {
return value === null || value === undefined;
};
/**
* Checks if value is a string.
*
* @param {*} value The value to check.
* @returns {boolean} Returns true if value is a string, else false.
*/
exports.isString = function isString(value) {
return typeof value === 'string';
};
/**
* Checks if value is an object type (not null, not an array).
*
* @param {*} value The value to check.
* @returns {boolean} Returns true if value is an object, else false.
*/
exports.isObject = function isObject(value) {
return value !== null && typeof value === 'object' && !Array.isArray(value);
};
/**
* Checks if object has a direct property (own property).
*
* @param {Object} object The object to check.
* @param {string} key The property name to check.
* @returns {boolean} Returns true if object has the property, else false.
*/
exports.has = function has(object, key) {
return object != null && Object.prototype.hasOwnProperty.call(object, key);
};
/**
* Checks if object has a property (including inherited properties).
*
* @param {Object} object The object to check.
* @param {string} key The property name to check.
* @returns {boolean} Returns true if object has the property, else false.
*/
exports.hasIn = function hasIn(object, key) {
return object != null && key in object;
};
/**
* Creates a new object excluding specified keys.
*
* @param {Object} object The source object.
* @param {Array<string>} keys The keys to exclude.
* @returns {Object} Returns the new object with specified keys omitted.
*/
exports.omit = function omit(object, keys) {
if (object == null) return {};
const result = {};
const keysToOmit = new Set(keys);
for (const key in object) {
if (
Object.prototype.hasOwnProperty.call(object, key) &&
!keysToOmit.has(key)
) {
result[key] = object[key];
}
}
return result;
};
/**
* Checks if value is empty (null, undefined, empty string, empty array, or empty object).
*
* @param {*} value The value to check.
* @returns {boolean} Returns true if value is empty, else false.
*/
exports.isEmpty = function isEmpty(value) {
if (value == null) return true;
if (typeof value === 'string' || Array.isArray(value)) {
return value.length === 0;
}
if (typeof value === 'object') {
return Object.keys(value).length === 0;
}
return false;
};
/**
* Gets the first element of an array.
*
* @param {Array} array The array to query.
* @returns {*} Returns the first element of array.
*/
exports.head = function head(array) {
return array != null ? array[0] : undefined;
};
================================================
FILE: src/aggregations/bucket-aggregations/adjacency-matrix-aggregation.js
================================================
'use strict';
const {
Query,
util: { checkType, setDefault }
} = require('../../core');
const BucketAggregationBase = require('./bucket-aggregation-base');
const ES_REF_URL =
'https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-adjacency-matrix-aggregation.html';
/**
* A bucket aggregation returning a form of adjacency matrix.
* The request provides a collection of named filter expressions,
* similar to the `filters` aggregation request. Each bucket in the response
* represents a non-empty cell in the matrix of intersecting filters.
*
* [Elasticsearch reference](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-adjacency-matrix-aggregation.html)
*
* @example
* const agg = esb.adjacencyMatrixAggregation('interactions').filters({
* grpA: esb.termsQuery('accounts', ['hillary', 'sidney']),
* grpB: esb.termsQuery('accounts', ['donald', 'mitt']),
* grpC: esb.termsQuery('accounts', ['vladimir', 'nigel'])
* });
*
* @param {string} name The name which will be used to refer to this aggregation.
*
* @extends BucketAggregationBase
*/
class AdjacencyMatrixAggregation extends BucketAggregationBase {
// eslint-disable-next-line require-jsdoc
constructor(name) {
super(name, 'adjacency_matrix');
}
/**
* @override
* @throws {Error} This method cannot be called on AdjacencyMatrixAggregation
*/
field() {
console.log(`Please refer ${ES_REF_URL}`);
throw new Error('field is not supported in AdjacencyMatrixAggregation');
}
/**
* @override
* @throws {Error} This method cannot be called on AdjacencyMatrixAggregation
*/
script() {
console.log(`Please refer ${ES_REF_URL}`);
throw new Error(
'script is not supported in AdjacencyMatrixAggregation'
);
}
/**
* Sets a named filter query.
*
* @param {string} filterName Name for the filter.
* @param {Query} filterQuery Query to filter on. Example - term query.
* @returns {AdjacencyMatrixAggregation} returns `this` so that calls can be chained
* @throws {TypeError} If `filterQuery` is not an instance of `Query`
*/
filter(filterName, filterQuery) {
checkType(filterQuery, Query);
setDefault(this._aggsDef, 'filters', {});
this._aggsDef.filters[filterName] = filterQuery;
return this;
}
/**
* Assigns filters to already added filters.
* Does not mix with anonymous filters.
* If anonymous filters are present, they will be overwritten.
*
* @param {Object} filterQueries Object with multiple key value pairs
* where filter name is the key and filter query is the value.
* @returns {AdjacencyMatrixAggregation} returns `this` so that calls can be chained
* @throws {TypeError} If `filterQueries` is not an instance of object
*/
filters(filterQueries) {
checkType(filterQueries, Object);
setDefault(this._aggsDef, 'filters', {});
Object.assign(this._aggsDef.filters, filterQueries);
return this;
}
/**
* Sets the `separator` parameter to use a separator string other than
* the default of the ampersand.
*
* @param {string} sep the string used to separate keys in intersections buckets
* e.g. & character for keyed filters A and B would return an
* intersection bucket named A&B
* @returns {AdjacencyMatrixAggregation} returns `this` so that calls can be chained
*/
separator(sep) {
this._aggsDef.separator = sep;
return this;
}
}
module.exports = AdjacencyMatrixAggregation;
================================================
FILE: src/aggregations/bucket-aggregations/auto-date-histogram-aggregation.js
================================================
'use strict';
const _ = require('../../_');
const BucketAggregationBase = require('./bucket-aggregation-base');
/**
* A multi-bucket aggregation similar to the Date histogram aggregation except instead of
* providing an interval to use as the width of each bucket, a target number of buckets
* is provided indicating the number of buckets needed and the interval of the buckets
* is automatically chosen to best achieve that target. The number of buckets returned
* will always be less than or equal to this target number.
*
* [Elasticsearch reference](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-autodatehistogram-aggregation.html)
*
* @example
* const agg = esb.autoDateHistogramAggregation('sales_over_time', 'date', 15);
*
* @param {string} name The name which will be used to refer to this aggregation.
* @param {string} field The field to aggregate on
* @param {number} buckets Bucket count to generate histogram over.
*
* @extends BucketAggregationBase
*/
class AutoDateHistogramAggregation extends BucketAggregationBase {
// eslint-disable-next-line require-jsdoc
constructor(name, field, buckets) {
super(name, 'auto_date_histogram', field);
if (!_.isNil(buckets)) this._aggsDef.buckets = buckets;
}
/**
* Sets the histogram bucket count. Buckets are generated based on this value.
*
* @param {number} buckets Bucket count to generate histogram over.
* @returns {AutoDateHistogramAggregation} returns `this` so that calls can be chained
*/
buckets(buckets) {
this._aggsDef.buckets = buckets;
return this;
}
/**
* The minimum_interval allows the caller to specify the minimum rounding interval that
* should be used. This can make the collection process more efficient, as the
* aggregation will not attempt to round at any interval lower than minimum_interval.
*
* Accepted units: year, month, day, hour, minute, second
*
* [Elasticsearch reference](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-autodatehistogram-aggregation.html#_minimum_interval_parameter)
*
* @example
* const agg = esb.autoDateHistogramAggregation(
* 'sales_over_time',
* 'date',
* 5
* ).minimumInterval('minute');
*
* @param {string} interval Minimum Rounding Interval Example: 'minute'
* @returns {AutoDateHistogramAggregation} returns `this` so that calls can be chained
*/
minimumInterval(interval) {
this._aggsDef.minimum_interval = interval;
return this;
}
/**
* Sets the format expression for `key_as_string` in response buckets.
* If no format is specified, then it will use the first format specified in the field mapping.
*
* @example
* const agg = esb.autoDateHistogramAggregation(
* 'sales_over_time',
* 'date',
* 5
* ).format('yyyy-MM-dd');
*
* @param {string} fmt Format mask to apply on aggregation response. Example: ####.00.
* For Date Histograms, supports expressive [date format pattern](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-daterange-aggregation.html#date-format-pattern)
* @returns {AutoDateHistogramAggregation} returns `this` so that calls can be chained
*/
format(fmt) {
this._aggsDef.format = fmt;
return this;
}
/**
* Sets the missing parameter which defines how documents
* that are missing a value should be treated.
*
* @example
* const agg = esb.autoDateHistogramAggregation('quantity', 'quantity', 10).missing(0);
*
* @param {string} value
* @returns {AutoDateHistogramAggregation} returns `this` so that calls can be chained
*/
missing(value) {
this._aggsDef.missing = value;
return this;
}
/**
* Date-times are stored in Elasticsearch in UTC.
* By default, all bucketing and rounding is also done in UTC.
* The `time_zone` parameter can be used to indicate that bucketing should use a different time zone.
* Sets the date time zone
*
* @example
* const agg = esb.autoDateHistogramAggregation('by_day', 'date', 15).timeZone(
* '-01:00'
* );
*
* @param {string} tz Time zone. Time zones may either be specified
* as an ISO 8601 UTC offset (e.g. +01:00 or -08:00) or as a timezone id,
* an identifier used in the TZ database like America/Los_Angeles.
* @returns {AutoDateHistogramAggregation} returns `this` so that calls can be chained
*/
timeZone(tz) {
this._aggsDef.time_zone = tz;
return this;
}
}
module.exports = AutoDateHistogramAggregation;
================================================
FILE: src/aggregations/bucket-aggregations/bucket-aggregation-base.js
================================================
'use strict';
const _ = require('../../_');
const {
Aggregation,
Script,
util: { checkType }
} = require('../../core');
/**
* The `BucketAggregationBase` provides support for common options used across
* various bucket `Aggregation` implementations.
*
* **NOTE:** Instantiating this directly should not be required.
* However, if you wish to add a custom implementation for whatever reason,
* this class could be extended.
*
* @param {string} name a valid aggregation name
* @param {string} aggType type of aggregation
* @param {string=} field The field to aggregate on
*
* @extends Aggregation
*/
class BucketAggregationBase extends Aggregation {
// eslint-disable-next-line require-jsdoc
constructor(name, aggType, field) {
super(name, aggType);
if (!_.isNil(field)) this._aggsDef.field = field;
}
/**
* Sets field to run aggregation on.
*
* @param {string} field a valid field name
* @returns {BucketAggregationBase} returns `this` so that calls can be chained
*/
field(field) {
this._aggsDef.field = field;
return this;
}
/**
* Sets script parameter for aggregation.
*
* @example
* // Generating the terms using a script
* const agg = esb.termsAggregation('genres').script(
* esb.script('file', 'my_script').params({ field: 'genre' })
* );
*
* @example
* // Value script
* const agg = esb.termsAggregation('genres', 'genre').script(
* esb.script('inline', "'Genre: ' +_value").lang('painless')
* );
*
* @param {Script} script
* @returns {BucketAggregationBase} returns `this` so that calls can be chained
* @throws {TypeError} If `script` is not an instance of `Script`
*/
script(script) {
checkType(script, Script);
this._aggsDef.script = script;
return this;
}
}
module.exports = BucketAggregationBase;
================================================
FILE: src/aggregations/bucket-aggregations/children-aggregation.js
================================================
'use strict';
const BucketAggregationBase = require('./bucket-aggregation-base');
const ES_REF_URL =
'https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-children-aggregation.html';
/**
* A special single bucket aggregation that enables aggregating
* from buckets on parent document types to buckets on child documents.
*
* This aggregation relies on the `_parent` field in the mapping.
*
* [Elasticsearch reference](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-children-aggregation.html)
*
* @example
* const reqBody = esb.requestBodySearch()
* .agg(
* esb.termsAggregation('top-tags', 'tags.keyword')
* .size(10)
* .agg(
* esb.childrenAggregation('to-answers')
* .type('answer')
* .agg(
* esb.termsAggregation(
* 'top-names',
* 'owner.display_name.keyword'
* ).size(10)
* )
* )
* )
* .size(0);
*
* @param {string} name The name which will be used to refer to this aggregation.
*
* @extends BucketAggregationBase
*/
class ChildrenAggregation extends BucketAggregationBase {
// eslint-disable-next-line require-jsdoc
constructor(name) {
super(name, 'children');
}
/**
* @override
* @throws {Error} This method cannot be called on ChildrenAggregation
*/
field() {
console.log(`Please refer ${ES_REF_URL}`);
throw new Error('field is not supported in ChildrenAggregation');
}
/**
* @override
* @throws {Error} This method cannot be called on ChildrenAggregation
*/
script() {
console.log(`Please refer ${ES_REF_URL}`);
throw new Error('script is not supported in ChildrenAggregation');
}
/**
* Sets the child type/mapping for aggregation.
*
* @param {string} type The child type that the buckets in the parent space should be mapped to.
* @returns {ChildrenAggregation} returns `this` so that calls can be chained
*/
type(type) {
this._aggsDef.type = type;
return this;
}
}
module.exports = ChildrenAggregation;
================================================
FILE: src/aggregations/bucket-aggregations/composite-agg-values-sources/date-histogram-values-source.js
================================================
'use strict';
const _ = require('../../../_');
const ValuesSourceBase = require('./values-source-base');
const REF_URL =
'https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-composite-aggregation.html#_date_histogram';
/**
* `DateHistogramValuesSource` is a source for the `CompositeAggregation` that
* handles date histograms. It works very similar to a histogram aggregation
* with a slightly different syntax.
*
* [Elasticsearch reference](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-composite-aggregation.html#_date_histogram)
*
* @example
* const valueSrc = esb.CompositeAggregation.dateHistogramValuesSource(
* 'date', // name
* 'timestamp', // field
* '1d' // interval
* );
*
* @param {string} name
* @param {string=} field The field to aggregate on
* @param {string|number=} interval Interval to generate histogram over.
*
* @extends ValuesSourceBase
*/
class DateHistogramValuesSource extends ValuesSourceBase {
// eslint-disable-next-line require-jsdoc
constructor(name, field, interval) {
super('date_histogram', REF_URL, name, field);
if (!_.isNil(interval)) this._opts.interval = interval;
}
/**
* Sets the histogram interval. Buckets are generated based on this interval value.
*
* @param {string|number} interval Interval to generate histogram over.
* @returns {DateHistogramValuesSource} returns `this` so that calls can be chained
*/
interval(interval) {
this._opts.interval = interval;
return this;
}
/**
* Calendar-aware intervals are configured with the calendarInterval parameter.
* The combined interval field for date histograms is deprecated from ES 7.2.
*
* @example
* const agg = esb.dateHistogramValuesSource('by_month', 'date').calendarInterval(
* 'month'
* );
*
* @param {string} interval Interval to generate histogram over.
* You can specify calendar intervals using the unit name, such as month, or as
* a single unit quantity, such as 1M. For example, day and 1d are equivalent.
* Multiple quantities, such as 2d, are not supported.
* @returns {DateHistogramValuesSource} returns `this` so that calls can be chained
*/
calendarInterval(interval) {
this._opts.calendar_interval = interval;
return this;
}
/**
* Fixed intervals are configured with the fixedInterval parameter.
* The combined interval field for date histograms is deprecated from ES 7.2.
*
* @example
* const agg = esb.dateHistogramValuesSource('by_minute', 'date').calendarInterval(
* '60s'
* );
*
* @param {string} interval Interval to generate histogram over.
* Intervals are a fixed number of SI units and never deviate, regardless
* of where they fall on the calendar. However, it means fixed intervals
* cannot express other units such as months, since the duration of a
* month is not a fixed quantity.
* The accepted units for fixed intervals are:
* millseconds (ms), seconds (s), minutes (m), hours (h) and days (d).
* @returns {DateHistogramValuesSource} returns `this` so that calls can be chained
*/
fixedInterval(interval) {
this._opts.fixed_interval = interval;
return this;
}
/**
* Sets the date time zone
*
* Date-times are stored in Elasticsearch in UTC. By default, all bucketing
* and rounding is also done in UTC. The `time_zone` parameter can be used
* to indicate that bucketing should use a different time zone.
*
* @param {string} tz Time zone. Time zones may either be specified
* as an ISO 8601 UTC offset (e.g. +01:00 or -08:00) or as a timezone id,
* an identifier used in the TZ database like America/Los_Angeles.
* @returns {DateHistogramValuesSource} returns `this` so that calls can be chained
*/
timeZone(tz) {
this._opts.time_zone = tz;
return this;
}
/**
* Sets the format expression for `key_as_string` in response buckets.
* If no format is specified, then it will use the first format specified
* in the field mapping.
*
* @example
* const valueSrc = esb.CompositeAggregation.valuesSource
* .dateHistogram('date', 'timestamp', '1d')
* .format('yyyy-MM-dd');
*
* @param {string} fmt Format mask to apply on aggregation response.
* For Date Histograms, supports expressive [date format pattern](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-daterange-aggregation.html#date-format-pattern)
* @returns {DateHistogramValuesSource} returns `this` so that calls can be chained
*/
format(fmt) {
this._opts.format = fmt;
return this;
}
}
module.exports = DateHistogramValuesSource;
================================================
FILE: src/aggregations/bucket-aggregations/composite-agg-values-sources/histogram-values-source.js
================================================
'use strict';
const _ = require('../../../_');
const ValuesSourceBase = require('./values-source-base');
const REF_URL =
'https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-composite-aggregation.html#_histogram';
/**
* `HistogramValuesSource` is a source for the `CompositeAggregation` that handles
* histograms. It works very similar to a histogram aggregation with a slightly
* different syntax.
*
* [Elasticsearch reference](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-composite-aggregation.html#_histogram)
*
* @example
* const valueSrc = esb.CompositeAggregation.histogramValuesSource(
* 'histo', // name
* 'price', // field
* 5 // interval
* );
*
* @param {string} name
* @param {string=} field The field to aggregate on
* @param {number=} interval Interval to generate histogram over.
*
* @extends ValuesSourceBase
*/
class HistogramValuesSource extends ValuesSourceBase {
// eslint-disable-next-line require-jsdoc
constructor(name, field, interval) {
super('histogram', REF_URL, name, field);
if (!_.isNil(interval)) this._opts.interval = interval;
}
/**
* Sets the histogram interval. Buckets are generated based on this interval value.
*
* @param {number} interval Interval to generate histogram over.
* @returns {HistogramValuesSource} returns `this` so that calls can be chained
*/
interval(interval) {
this._opts.interval = interval;
return this;
}
}
module.exports = HistogramValuesSource;
================================================
FILE: src/aggregations/bucket-aggregations/composite-agg-values-sources/index.js
================================================
'use strict';
exports.ValuesSourceBase = require('./values-source-base');
exports.TermsValuesSource = require('./terms-values-source');
exports.HistogramValuesSource = require('./histogram-values-source');
exports.DateHistogramValuesSource = require('./date-histogram-values-source');
================================================
FILE: src/aggregations/bucket-aggregations/composite-agg-values-sources/terms-values-source.js
================================================
'use strict';
const ValuesSourceBase = require('./values-source-base');
const REF_URL =
'https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-composite-aggregation.html#_terms';
/**
* `TermsValuesSource` is a source for the `CompositeAggregation` that handles
* terms. It works very similar to a terms aggregation with a slightly different
* syntax.
*
* [Elasticsearch reference](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-composite-aggregation.html#_terms)
*
* @example
* const valueSrc = esb.CompositeAggregation.termsValuesSource('product').script({
* source: "doc['product'].value",
* lang: 'painless'
* });
*
* @param {string} name
* @param {string=} field The field to aggregate on
*
* @extends ValuesSourceBase
*/
class TermsValuesSource extends ValuesSourceBase {
// eslint-disable-next-line require-jsdoc
constructor(name, field) {
super('terms', REF_URL, name, field);
}
}
module.exports = TermsValuesSource;
================================================
FILE: src/aggregations/bucket-aggregations/composite-agg-values-sources/values-source-base.js
================================================
'use strict';
const _ = require('../../../_');
const {
util: { invalidParam, recursiveToJSON }
} = require('../../../core');
const invalidOrderParam = invalidParam('', 'order', "'asc' or 'desc'");
/**
* Base class implementation for all Composite Aggregation values sources.
*
* **NOTE:** Instantiating this directly should not be required.
*
* @param {string} valueSrcType Type of value source
* @param {string} refUrl Elasticsearch reference URL
* @param {string} name
* @param {string=} field The field to aggregate on
*
* @throws {Error} if `name` is empty
* @throws {Error} if `valueSrcType` is empty
*/
class ValuesSourceBase {
// eslint-disable-next-line require-jsdoc
constructor(valueSrcType, refUrl, name, field) {
if (_.isEmpty(valueSrcType))
throw new Error('ValuesSourceBase `valueSrcType` cannot be empty');
this._name = name;
this._valueSrcType = valueSrcType;
this._refUrl = refUrl;
this._body = {};
this._opts = this._body[valueSrcType] = {};
if (!_.isNil(field)) this._opts.field = field;
}
/**
* Field to use for this source.
*
* @param {string} field a valid field name
* @returns {ValuesSourceBase} returns `this` so that calls can be chained
*/
field(field) {
this._opts.field = field;
return this;
}
/**
* Script to use for this source.
*
* @param {Script|Object|string} script
* @returns {ValuesSourceBase} returns `this` so that calls can be chained
* @throws {TypeError} If `script` is not an instance of `Script`
*/
script(script) {
this._opts.script = script;
return this;
}
/**
* Specifies the type of values produced by this source, e.g. `string` or
* `date`.
*
* @param {string} valueType
* @returns {ValuesSourceBase} returns `this` so that calls can be chained
*/
valueType(valueType) {
this._opts.value_type = valueType;
return this;
}
/**
* Order specifies the order in the values produced by this source. It can
* be either `asc` or `desc`.
*
* @param {string} order The `order` option can have the following values.
* `asc`, `desc` to sort in ascending, descending order respectively.
* @returns {ValuesSourceBase} returns `this` so that calls can be chained.
*/
order(order) {
if (_.isNil(order)) invalidOrderParam(order, this._refUrl);
const orderLower = order.toLowerCase();
if (orderLower !== 'asc' && orderLower !== 'desc') {
invalidOrderParam(order, this._refUrl);
}
this._opts.order = orderLower;
return this;
}
/**
* Missing specifies the value to use when the source finds a missing value
* in a document.
*
* Note: This option was deprecated in
* [Elasticsearch v6](https://www.elastic.co/guide/en/elasticsearch/reference/6.8/breaking-changes-6.0.html#_literal_missing_literal_is_deprecated_in_the_literal_composite_literal_aggregation).
* From 6.4 and later, use `missing_bucket` instead.
*
* @param {string|number} value
* @returns {ValuesSourceBase} returns `this` so that calls can be chained
*/
missing(value) {
this._opts.missing = value;
return this;
}
/**
* Specifies whether to include documents without a value for a given source
* in the response. Defaults to `false` (not included).
*
* Note: This method is incompatible with elasticsearch 6.3 and older.
* Use it only with elasticsearch 6.4 and later.
*
* @param {boolean} value
* @returns {ValuesSourceBase} returns `this` so that calls can be chained
*/
missingBucket(value) {
this._opts.missing_bucket = value;
return this;
}
/**
* Override default `toJSON` to return DSL representation for the Composite
* Aggregation values source.
*
* @override
* @returns {Object} returns an Object which maps to the elasticsearch query DSL
*/
toJSON() {
return { [this._name]: recursiveToJSON(this._body) };
}
}
module.exports = ValuesSourceBase;
================================================
FILE: src/aggregations/bucket-aggregations/composite-aggregation.js
================================================
'use strict';
const {
Aggregation,
util: { checkType, constructorWrapper }
} = require('../../core');
const {
ValuesSourceBase,
TermsValuesSource,
HistogramValuesSource,
DateHistogramValuesSource
} = require('./composite-agg-values-sources');
/**
* CompositeAggregation is a multi-bucket values source based aggregation that
* can be used to calculate unique composite values from source documents.
*
* Unlike the other multi-bucket aggregation the composite aggregation can be
* used to paginate **all** buckets from a multi-level aggregation efficiently.
* This aggregation provides a way to stream **all** buckets of a specific
* aggregation similarly to what scroll does for documents.
*
* [Elasticsearch reference](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-composite-aggregation.html)
*
* @example
* const reqBody = esb.requestBodySearch()
* .agg(
* esb.compositeAggregation('my_buckets')
* .sources(
* esb.CompositeAggregation.termsValuesSource('product', 'product')
* )
* )
*
* NOTE: This query was added in elasticsearch v6.1.
*
* @param {string} name a valid aggregation name
*
* @extends Aggregation
*/
class CompositeAggregation extends Aggregation {
// eslint-disable-next-line require-jsdoc
constructor(name) {
super(name, 'composite');
this._aggsDef.sources = [];
}
/**
* Specifies the Composite Aggregation values sources to use in the
* aggregation.
*
* @example
* const { CompositeAggregation } = esb;
* const reqBody = esb.requestBodySearch()
* .agg(
* esb.compositeAggregation('my_buckets')
* .sources(
* CompositeAggregation.dateHistogramValuesSource(
* 'date',
* 'timestamp',
* '1d'
* ),
* CompositeAggregation.termsValuesSource('product', 'product')
* )
* );
*
* @param {...ValuesSourceBase} sources
* @returns {CompositeAggregation} returns `this` so that calls can be chained
* @throws {TypeError} If any of the rest parameters `sources` is not an
* instance of `ValuesSourceBase`
*/
sources(...sources) {
sources.forEach(valueSrc => checkType(valueSrc, ValuesSourceBase));
this._aggsDef.sources = this._aggsDef.sources.concat(sources);
return this;
}
/**
* Defines how many composite buckets should be returned. Each composite
* bucket is considered as a single bucket so setting a size of 10 will
* return the first 10 composite buckets created from the values source. The
* response contains the values for each composite bucket in an array
* containing the values extracted from each value source.
*
* @param {number} size
* @returns {CompositeAggregation} returns `this` so that calls can be chained
*/
size(size) {
this._aggsDef.size = size;
return this;
}
/**
* The `after` parameter can be used to retrieve the composite buckets that
* are after the last composite buckets returned in a previous round.
*
* @example
* const { CompositeAggregation } = esb;
* const reqBody = esb.requestBodySearch().agg(
* esb.compositeAggregation('my_buckets')
* .size(2)
* .sources(
* CompositeAggregation.dateHistogramValuesSource(
* 'date',
* 'timestamp',
* '1d'
* ).order('desc'),
* CompositeAggregation.termsValuesSource('product', 'product').order('asc')
* )
* .after({ date: 1494288000000, product: 'mad max' })
* );
*
* @param {Object} afterKey
* @returns {CompositeAggregation} returns `this` so that calls can be chained
*/
after(afterKey) {
this._aggsDef.after = afterKey;
return this;
}
}
CompositeAggregation.TermsValuesSource = TermsValuesSource;
CompositeAggregation.termsValuesSource = constructorWrapper(TermsValuesSource);
CompositeAggregation.HistogramValuesSource = HistogramValuesSource;
CompositeAggregation.histogramValuesSource = constructorWrapper(
HistogramValuesSource
);
CompositeAggregation.DateHistogramValuesSource = DateHistogramValuesSource;
CompositeAggregation.dateHistogramValuesSource = constructorWrapper(
DateHistogramValuesSource
);
module.exports = CompositeAggregation;
================================================
FILE: src/aggregations/bucket-aggregations/date-histogram-aggregation.js
================================================
'use strict';
const HistogramAggregationBase = require('./histogram-aggregation-base');
/**
* A multi-bucket aggregation similar to the histogram except it can only be applied on date values.
* The interval can be specified by date/time expressions.
*
* [Elasticsearch reference](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-datehistogram-aggregation.html#_scripts)
*
* @example
* const agg = esb.dateHistogramAggregation('sales_over_time', 'date', 'month');
*
* @example
* const agg = esb.dateHistogramAggregation(
* 'sales_over_time',
* 'date',
* '1M'
* ).format('yyyy-MM-dd');
*
* @param {string} name The name which will be used to refer to this aggregation.
* @param {string=} field The field to aggregate on
* @param {string=} interval Interval to generate histogram over.
* Available expressions for interval: year, quarter, month, week, day, hour, minute, second
*
* @extends HistogramAggregationBase
*/
class DateHistogramAggregation extends HistogramAggregationBase {
// eslint-disable-next-line require-jsdoc
constructor(name, field, interval) {
super(name, 'date_histogram', field, interval);
}
/**
* Date-times are stored in Elasticsearch in UTC.
* By default, all bucketing and rounding is also done in UTC.
* The `time_zone` parameter can be used to indicate that bucketing should use a different time zone.
* Sets the date time zone
*
* @example
* const agg = esb.dateHistogramAggregation('by_day', 'date', 'day').timeZone(
* '-01:00'
* );
*
* @param {string} tz Time zone. Time zones may either be specified
* as an ISO 8601 UTC offset (e.g. +01:00 or -08:00) or as a timezone id,
* an identifier used in the TZ database like America/Los_Angeles.
* @returns {DateHistogramAggregation} returns `this` so that calls can be chained
*/
timeZone(tz) {
this._aggsDef.time_zone = tz;
return this;
}
/**
* Calendar-aware intervals are configured with the calendarInterval parameter.
* The combined interval field for date histograms is deprecated from ES 7.2.
*
* @example
* const agg = esb.dateHistogramAggregation('by_month', 'date').calendarInterval(
* 'month'
* );
*
* @param {string} interval Interval to generate histogram over.
* You can specify calendar intervals using the unit name, such as month, or as
* a single unit quantity, such as 1M. For example, day and 1d are equivalent.
* Multiple quantities, such as 2d, are not supported.
* @returns {DateHistogramAggregation} returns `this` so that calls can be chained
*/
calendarInterval(interval) {
this._aggsDef.calendar_interval = interval;
return this;
}
/**
* Fixed intervals are configured with the fixedInterval parameter.
* The combined interval field for date histograms is deprecated from ES 7.2.
*
* @param {string} interval Interval to generate histogram over.
* Intervals are a fixed number of SI units and never deviate, regardless
* of where they fall on the calendar. However, it means fixed intervals
* cannot express other units such as months, since the duration of a
* month is not a fixed quantity.
*
* @example
* const agg = esb.dateHistogramAggregation('by_minute', 'date').calendarInterval(
* '60s'
* );
*
* The accepted units for fixed intervals are:
* millseconds (ms), seconds (s), minutes (m), hours (h) and days (d).
* @returns {DateHistogramAggregation} returns `this` so that calls can be chained
*/
fixedInterval(interval) {
this._aggsDef.fixed_interval = interval;
return this;
}
}
module.exports = DateHistogramAggregation;
================================================
FILE: src/aggregations/bucket-aggregations/date-range-aggregation.js
================================================
'use strict';
const RangeAggregationBase = require('./range-aggregation-base');
/**
* A range aggregation that is dedicated for date values. The main difference
* between this aggregation and the normal range aggregation is that the from
* and to values can be expressed in Date Math expressions, and it is also
* possible to specify a date format by which the from and to response fields
* will be returned.
*
* [Elasticsearch reference](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-daterange-aggregation.html)
*
* @example
* const agg = esb.dateRangeAggregation('range', 'date')
* .format('MM-yyy')
* .ranges([{ to: 'now-10M/M' }, { from: 'now-10M/M' }]);
*
* @param {string} name The name which will be used to refer to this aggregation.
* @param {string=} field The field to aggregate on
*
* @extends RangeAggregationBase
*/
class DateRangeAggregation extends RangeAggregationBase {
// eslint-disable-next-line require-jsdoc
constructor(name, field) {
super(name, 'date_range', field);
}
/**
* Sets the date time zone.
* Date-times are stored in Elasticsearch in UTC.
* By default, all bucketing and rounding is also done in UTC.
* The `time_zone` parameter can be used to indicate that
* bucketing should use a different time zone.
*
* @example
* const agg = esb.dateRangeAggregation('range', 'date')
* .timeZone('CET')
* .ranges([
* { to: '2016/02/01' },
* { from: '2016/02/01', to: 'now/d' },
* { from: 'now/d' }
* ]);
*
* @param {string} tz Time zone. Time zones may either be specified
* as an ISO 8601 UTC offset (e.g. +01:00 or -08:00) or as a timezone id,
* an identifier used in the TZ database like America/Los_Angeles.
* @returns {DateRangeAggregation} returns `this` so that calls can be chained
*/
timeZone(tz) {
this._aggsDef.time_zone = tz;
return this;
}
}
module.exports = DateRangeAggregation;
================================================
FILE: src/aggregations/bucket-aggregations/diversified-sampler-aggregation.js
================================================
'use strict';
const _ = require('../../_');
const {
util: { invalidParam },
consts: { EXECUTION_HINT_SET }
} = require('../../core');
const BucketAggregationBase = require('./bucket-aggregation-base');
const ES_REF_URL =
'https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-diversified-sampler-aggregation.html';
const invalidExecutionHintParam = invalidParam(
ES_REF_URL,
'execution_hint',
EXECUTION_HINT_SET
);
/**
* A filtering aggregation used to limit any sub aggregations' processing
* to a sample of the top-scoring documents. Diversity settings
* are used to limit the number of matches that share a common value such as an "author".
*
* [Elasticsearch reference](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-diversified-sampler-aggregation.html)
*
* @example
* const reqBody = esb.requestBodySearch()
* .query(esb.queryStringQuery('tags:elasticsearch'))
* .agg(
* esb.diversifiedSamplerAggregation('my_unbiased_sample', 'author')
* .shardSize(200)
* .agg(
* esb.significantTermsAggregation(
* 'keywords',
* 'tags'
* ).exclude(['elasticsearch'])
* )
* );
*
* @example
* // Use a script to produce a hash of the multiple values in a tags field
* // to ensure we don't have a sample that consists of the same repeated
* // combinations of tags
* const reqBody = esb.requestBodySearch()
* .query(esb.queryStringQuery('tags:kibana'))
* .agg(
* esb.diversifiedSamplerAggregation('my_unbiased_sample')
* .shardSize(200)
* .maxDocsPerValue(3)
* .script(esb.script('inline', "doc['tags'].values.hashCode()"))
* .agg(
* esb.significantTermsAggregation(
* 'keywords',
* 'tags'
* ).exclude(['kibana'])
* )
* );
*
* @param {string} name The name which will be used to refer to this aggregation.
* @param {string=} field The field to aggregate on
*
* @extends BucketAggregationBase
*/
class DiversifiedSamplerAggregation extends BucketAggregationBase {
// eslint-disable-next-line require-jsdoc
constructor(name, field) {
super(name, 'diversified_sampler', field);
}
/**
* The shard_size parameter limits how many top-scoring documents
* are collected in the sample processed on each shard. The default value is 100.
*
* @param {number} size Maximum number of documents to return from each shard(Integer)
* @returns {DiversifiedSamplerAggregation} returns `this` so that calls can be chained
*/
shardSize(size) {
this._aggsDef.shard_size = size;
return this;
}
/**
* Used to control the maximum number of documents collected
* on any one shard which share a common value.
* Applies on a per-shard basis only for the purposes of shard-local sampling.
*
* @param {number} maxDocsPerValue Default 1.(Integer)
* @returns {DiversifiedSamplerAggregation} returns `this` so that calls can be chained
*/
maxDocsPerValue(maxDocsPerValue) {
this._aggsDef.max_docs_per_value = maxDocsPerValue;
return this;
}
/**
* This setting can influence the management of the values used
* for de-duplication. Each option will hold up to shard_size
* values in memory while performing de-duplication but
* the type of value held can be controlled
*
* @param {string} hint the possible values are `map`, `global_ordinals`,
* `global_ordinals_hash` and `global_ordinals_low_cardinality`
* @returns {DiversifiedSamplerAggregation} returns `this` so that calls can be chained
* @throws {Error} If Execution Hint is outside the accepted set.
*/
executionHint(hint) {
if (_.isNil(hint)) invalidExecutionHintParam(hint);
const hintLower = hint.toLowerCase();
if (!EXECUTION_HINT_SET.has(hintLower)) {
invalidExecutionHintParam(hint);
}
this._aggsDef.execution_hint = hintLower;
return this;
}
}
module.exports = DiversifiedSamplerAggregation;
================================================
FILE: src/aggregations/bucket-aggregations/filter-aggregation.js
================================================
'use strict';
const _ = require('../../_');
const {
Query,
util: { checkType }
} = require('../../core');
const BucketAggregationBase = require('./bucket-aggregation-base');
const ES_REF_URL =
'https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filter-aggregation.html';
/**
* Defines a single bucket of all the documents in the current document set
* context that match a specified filter. Often this will be used to narrow down
* the current aggregation context to a specific set of documents.
*
* [Elasticsearch reference](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filter-aggregation.html)
*
* @example
* const reqBody = esb.requestBodySearch()
* .agg(
* esb.filterAggregation(
* 't_shirts',
* esb.termQuery('type', 't-shirt')
* ).agg(esb.avgAggregation('avg_price', 'price'))
* )
* .size(0);
*
* @param {string} name The name which will be used to refer to this aggregation.
* @param {Query=} filterQuery Query to filter on. Example - term query.
*
* @extends BucketAggregationBase
*/
class FilterAggregation extends BucketAggregationBase {
// eslint-disable-next-line require-jsdoc
constructor(name, filterQuery) {
super(name, 'filter');
if (!_.isNil(filterQuery)) this.filter(filterQuery);
}
/**
* @override
* @throws {Error} This method cannot be called on FilterAggregation
*/
field() {
console.log(`Please refer ${ES_REF_URL}`);
throw new Error('field is not supported in FilterAggregation');
}
/**
* @override
* @throws {Error} This method cannot be called on FilterAggregation
*/
script() {
console.log(`Please refer ${ES_REF_URL}`);
throw new Error('script is not supported in FilterAggregation');
}
// NOTE: Special case. filter does not set a key inside
// this._aggsDef but sets the entire object itself
// Generic getOpt will fail for this.
// Just a simple override should handle it though
/**
* Set the filter query for Filter Aggregation.
*
* @param {Query} filterQuery Query to filter on. Example - term query.
* @returns {FilterAggregation} returns `this` so that calls can be chained
* @throws {TypeError} If `filterQuery` is not an instance of `Query`
*/
filter(filterQuery) {
checkType(filterQuery, Query);
this._aggsDef = this._aggs[this.aggType] = filterQuery;
return this;
}
}
module.exports = FilterAggregation;
================================================
FILE: src/aggregations/bucket-aggregations/filters-aggregation.js
================================================
'use strict';
const _ = require('../../_');
const {
Query,
util: { checkType, setDefault }
} = require('../../core');
const BucketAggregationBase = require('./bucket-aggregation-base');
const ES_REF_URL =
'https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filters-aggregation.html';
/**
* Defines a single bucket of all the documents in the current document set
* context that match a specified filter. Often this will be used to narrow down
* the current aggregation context to a specific set of documents.
*
* [Elasticsearch reference](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filters-aggregation.html)
*
* @example
* const agg = esb.filtersAggregation('messages')
* .filter('errors', esb.matchQuery('body', 'error'))
* .filter('warnings', esb.matchQuery('body', 'warning'));
*
*
* @example
* const agg = esb.filtersAggregation('messages')
* .anonymousFilters([
* esb.matchQuery('body', 'error'),
* esb.matchQuery('body', 'warning')
* ])
*
* @param {string} name The name which will be used to refer to this aggregation.
*
* @extends BucketAggregationBase
*/
class FiltersAggregation extends BucketAggregationBase {
// eslint-disable-next-line require-jsdoc
constructor(name) {
super(name, 'filters');
}
/**
* @override
* @throws {Error} This method cannot be called on FiltersAggregation
*/
field() {
console.log(`Please refer ${ES_REF_URL}`);
throw new Error('field is not supported in FiltersAggregation');
}
/**
* @override
* @throws {Error} This method cannot be called on FiltersAggregation
*/
script() {
console.log(`Please refer ${ES_REF_URL}`);
throw new Error('script is not supported in FiltersAggregation');
}
/**
* Print warning message to console namespaced by class name.
*
* @param {string} msg
* @private
*/
_warn(msg) {
console.warn(`[FiltersAggregation] ${msg}`);
}
/**
* Check and puts an object for the `filters` key in
* internal aggregation representation object.
* If the key has a value but is not an object,
* a warning is printed.
* @private
*/
_checkNamedFilters() {
if (
!setDefault(this._aggsDef, 'filters', {}) &&
Array.isArray(this._aggsDef.filters)
) {
this._warn('Do not mix named and anonymous filters!');
this._warn('Overwriting anonymous filters.');
this._aggsDef.filters = {};
}
}
/**
* Check and puts an array for the `filters` key in
* internal aggregation representation object.
* If the key has a value but is not an array,
* a warning is printed.
* @private
*/
_checkAnonymousFilters() {
if (
!setDefault(this._aggsDef, 'filters', []) &&
!Array.isArray(this._aggsDef.filters)
) {
this._warn('Do not mix named and anonymous filters!');
this._warn('Overwriting named filters.');
this._aggsDef.filters = [];
}
}
/**
* Sets a named filter query.
* Does not mix with anonymous filters.
* If anonymous filters are present, they will be overwritten.
*
* @param {string} bucketName Name for bucket which will collect
* all documents that match its associated filter.
* @param {Query} filterQuery Query to filter on. Example - term query.
* @returns {FiltersAggregation} returns `this` so that calls can be chained
* @throws {TypeError} If `filterQuery` is not an instance of `Query`
*/
filter(bucketName, filterQuery) {
checkType(filterQuery, Query);
this._checkNamedFilters();
this._aggsDef.filters[bucketName] = filterQuery;
return this;
}
/**
* Assigns filters to already added filters.
* Does not mix with anonymous filters.
* If anonymous filters are present, they will be overwritten.
*
* @param {Object} filterQueries Object with multiple key value pairs
* where bucket name is the key and filter query is the value.
* @returns {FiltersAggregation} returns `this` so that calls can be chained
* @throws {TypeError} If `filterQueries` is not an instance of object
*/
filters(filterQueries) {
checkType(filterQueries, Object);
this._checkNamedFilters();
Object.assign(this._aggsDef.filters, filterQueries);
return this;
}
/**
* Appends an anonymous filter query.
* Does not mix with named filters.
* If named filters are present, they will be overwritten.
*
* @param {*} filterQuery Query to filter on. Example - term query.
* @returns {FiltersAggregation} returns `this` so that calls can be chained
* @throws {TypeError} If `filterQuery` is not an instance of `Query`
*/
anonymousFilter(filterQuery) {
checkType(filterQuery, Query);
this._checkAnonymousFilters();
this._aggsDef.filters.push(filterQuery);
return this;
}
/**
* Appends an array of anonymous filters.
* Does not mix with named filters.
* If named filters are present, they will be overwritten.
*
* @param {*} filterQueries Array of queries to filter on and generate buckets.
* Example - term query.
* @returns {FiltersAggregation} returns `this` so that calls can be chained
* @throws {TypeError} If `filterQueries` is not an instance of Array
*/
anonymousFilters(filterQueries) {
checkType(filterQueries, Array);
this._checkAnonymousFilters();
this._aggsDef.filters = this._aggsDef.filters.concat(filterQueries);
return this;
}
/**
* Adds a bucket to the response which will contain all documents
* that do not match any of the given filters.
* Returns the other bucket bucket either in a bucket
* (named `_other_` by default) if named filters are being used,
* or as the last bucket if anonymous filters are being used
*
* @param {boolean} enable `True` to return `other` bucket with documents
* that do not match any filters and `False` to disable computation
* @param {string=} otherBucketKey Optional key for the other bucket.
* Default is `_other_`.
* @returns {FiltersAggregation} returns `this` so that calls can be chained
*/
otherBucket(enable, otherBucketKey) {
this._aggsDef.other_bucket = enable;
!_.isEmpty(otherBucketKey) && this.otherBucketKey(otherBucketKey);
return this;
}
/**
* Sets the key for the other bucket to a value other than the default `_other_`.
* Setting this parameter will implicitly set the other_bucket parameter to true.
* If anonymous filters are being used, setting this parameter will not make sense.
*
* @example
* const agg = esb.filtersAggregation('messages')
* .filter('errors', esb.matchQuery('body', 'error'))
* .filter('warnings', esb.matchQuery('body', 'warning'))
* .otherBucketKey('other_messages');
*
* @param {string} otherBucketKey
* @returns {FiltersAggregation} returns `this` so that calls can be chained
*/
otherBucketKey(otherBucketKey) {
this._aggsDef.other_bucket_key = otherBucketKey;
return this;
}
}
module.exports = FiltersAggregation;
================================================
FILE: src/aggregations/bucket-aggregations/geo-distance-aggregation.js
================================================
'use strict';
const _ = require('../../_');
const {
GeoPoint,
util: { checkType, invalidParam },
consts: { UNIT_SET }
} = require('../../core');
const RangeAggregationBase = require('./range-aggregation-base');
const ES_REF_URL =
'https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-geodistance-aggregation.html';
const invalidUnitParam = invalidParam(ES_REF_URL, 'unit', UNIT_SET);
const invalidDistanceTypeParam = invalidParam(
ES_REF_URL,
'distance_type',
"'plane' or 'arc'"
);
/**
* A multi-bucket aggregation that works on geo_point fields and conceptually
* works very similar to the range aggregation. The user can define a point of
* origin and a set of distance range buckets. The aggregation evaluate the
* distance of each document value from the origin point and determines the
* buckets it belongs to based on the ranges (a document belongs to a bucket
* if the distance between the document and the origin falls within the distance
* range of the bucket).
*
* [Elasticsearch reference](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-geodistance-aggregation.html)
*
* @example
* const agg = esb.geoDistanceAggregation('rings_around_amsterdam', 'location')
* .origin(esb.geoPoint().string('52.3760, 4.894'))
* .ranges([{ to: 100000 }, { from: 100000, to: 300000 }, { from: 300000 }]);
*
* @param {string} name The name which will be used to refer to this aggregation.
* @param {string=} field The field to aggregate on
*
* @extends RangeAggregationBase
*/
class GeoDistanceAggregation extends RangeAggregationBase {
// eslint-disable-next-line require-jsdoc
constructor(name, field) {
super(name, 'geo_distance', field);
}
/**
* @override
* @throws {Error} This method cannot be called on GeoDistanceAggregation
*/
format() {
console.log(`Please refer ${ES_REF_URL}`);
throw new Error('format is not supported in GeoDistanceAggregation');
}
/**
* @override
* @throws {Error} This method cannot be called on GeoDistanceAggregation
*/
script() {
console.log(`Please refer ${ES_REF_URL}`);
throw new Error('script is not supported in GeoDistanceAggregation');
}
/**
* Sets the point of origin from where distances will be measured.
*
* @param {GeoPoint} point A valid `GeoPoint` object.
* @returns {GeoDistanceAggregation} returns `this` so that calls can be chained
* @throws {TypeError} If `point` is not an instance of `GeoPoint`
*/
origin(point) {
checkType(point, GeoPoint);
this._aggsDef.origin = point;
return this;
}
/**
* Sets the distance unit. Valid values are:
* mi (miles), in (inches), yd (yards),
* km (kilometers), cm (centimeters), mm (millimeters),
* ft(feet), NM(nauticalmiles)
*
* @example
* const agg = esb.geoDistanceAggregation('rings_around_amsterdam', 'location')
* .origin(esb.geoPoint().string('52.3760, 4.894'))
* .unit('km')
* .ranges([{ to: 100 }, { from: 100, to: 300 }, { from: 300 }]);
*
* @param {string} unit Distance unit, default is `m`(meters).
* @returns {GeoDistanceAggregation} returns `this` so that calls can be chained
* @throws {Error} If Unit is outside the accepted set.
*/
unit(unit) {
if (!UNIT_SET.has(unit)) {
invalidUnitParam(unit);
}
this._aggsDef.unit = unit;
return this;
}
/**
* Sets the distance calculation mode, `arc` or `plane`.
* The `arc` calculation is the more accurate.
* The `plane` is the faster but least accurate.
*
* @example
* const agg = esb.geoDistanceAggregation('rings_around_amsterdam', 'location')
* .origin(esb.geoPoint().string('52.3760, 4.894'))
* .unit('km')
* .distanceType('plane')
* .ranges([{ to: 100 }, { from: 100, to: 300 }, { from: 300 }]);
*
* @param {string} type
* @returns {GeoDistanceAggregation} returns `this` so that calls can be chained
* @throws {Error} If `type` is neither `plane` nor `arc`.
*/
distanceType(type) {
if (_.isNil(type)) invalidDistanceTypeParam(type);
const typeLower = type.toLowerCase();
if (typeLower !== 'plane' && typeLower !== 'arc')
invalidDistanceTypeParam(type);
this._aggsDef.distance_type = typeLower;
return this;
}
}
module.exports = GeoDistanceAggregation;
================================================
FILE: src/aggregations/bucket-aggregations/geo-hash-grid-aggregation.js
================================================
'use strict';
const _ = require('../../_');
const BucketAggregationBase = require('./bucket-aggregation-base');
const ES_REF_URL =
'https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-geohashgrid-aggregation.html';
/**
* A multi-bucket aggregation that works on geo_point fields and groups points
* into buckets that represent cells in a grid. The resulting grid can be sparse
* and only contains cells that have matching data. Each cell is labeled using a
* geohash which is of user-definable precision.
* [Elasticsearch reference](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-geohashgrid-aggregation.html)
*
* @example
* const agg = esb.geoHashGridAggregation('large-grid', 'location').precision(3);
*
* @param {string} name The name which will be used to refer to this aggregation.
* @param {string=} field The field to aggregate on
*
* @extends BucketAggregationBase
*/
class GeoHashGridAggregation extends BucketAggregationBase {
// eslint-disable-next-line require-jsdoc
constructor(name, field) {
super(name, 'geohash_grid', field);
}
/**
* @override
* @throws {Error} This method cannot be called on GeoHashGridAggregation
*/
format() {
console.log(`Please refer ${ES_REF_URL}`);
throw new Error('format is not supported in GeoHashGridAggregation');
}
/**
* @override
* @throws {Error} This method cannot be called on GeoHashGridAggregation
*/
script() {
console.log(`Please refer ${ES_REF_URL}`);
throw new Error('script is not supported in GeoHashGridAggregation');
}
/**
* Sets the precision for the generated geohash.
*
* @param {number} precision Precision can be between 1 and 12
* @returns {GeoHashGridAggregation} returns `this` so that calls can be chained
* @throws {Error} If precision is not between 1 and 12.
*/
precision(precision) {
if (_.isNil(precision) || precision < 1 || precision > 12) {
throw new Error('`precision` can only be value from 1 to 12.');
}
this._aggsDef.precision = precision;
return this;
}
/**
* Sets the maximum number of geohash buckets to return.
* When results are trimmed, buckets are prioritised
* based on the volumes of documents they contain.
*
* @param {number} size Optional. The maximum number of geohash
* buckets to return (defaults to 10,000).
* @returns {GeoHashGridAggregation} returns `this` so that calls can be chained
*/
size(size) {
this._aggsDef.size = size;
return this;
}
/**
* Determines how many geohash_grid the coordinating node
* will request from each shard.
*
* @param {number} shardSize Optional.
* @returns {GeoHashGridAggregation} returns `this` so that calls can be chained
*/
shardSize(shardSize) {
this._aggsDef.shard_size = shardSize;
return this;
}
}
module.exports = GeoHashGridAggregation;
================================================
FILE: src/aggregations/bucket-aggregations/geo-hex-grid-aggregation.js
================================================
'use strict';
const _ = require('../../_');
const BucketAggregationBase = require('./bucket-aggregation-base');
const ES_REF_URL =
'https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-geohexgrid-aggregation.html';
/**
* A multi-bucket aggregation that groups geo_point and geo_shape values into buckets
* that represent a grid. The resulting grid can be sparse and only contains cells
* that have matching data. Each cell corresponds to a H3 cell index and is labeled
* using the H3Index representation.
* [Elasticsearch reference](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-geohexgrid-aggregation.html)
*
* NOTE: This aggregation was added in elasticsearch v8.1.0.
*
* @example
* const agg = esb.geoHexGridAggregation('hex-grid', 'location').precision(3);
*
* @param {string} name The name which will be used to refer to this aggregation.
* @param {string=} field The field to aggregate on
*
* @extends BucketAggregationBase
*/
class GeoHexGridAggregation extends BucketAggregationBase {
// eslint-disable-next-line require-jsdoc
constructor(name, field) {
super(name, 'geohex_grid', field);
}
/**
* @override
* @throws {Error} This method cannot be called on GeoHexGridAggregation
*/
format() {
console.log(`Please refer ${ES_REF_URL}`);
throw new Error('format is not supported in GeoHexGridAggregation');
}
/**
* @override
* @throws {Error} This method cannot be called on GeoHexGridAggregation
*/
script() {
console.log(`Please refer ${ES_REF_URL}`);
throw new Error('script is not supported in GeoHexGridAggregation');
}
/**
* Sets the precision for the generated geohex.
*
* @param {number} precision Precision can be between 0 and 15
* @returns {GeoHexGridAggregation} returns `this` so that calls can be chained
* @throws {Error} If precision is not between 0 and 15.
*/
precision(precision) {
if (_.isNil(precision) || precision < 0 || precision > 15) {
throw new Error('`precision` can only be value from 0 to 15.');
}
this._aggsDef.precision = precision;
return this;
}
/**
* Sets the maximum number of geohex buckets to return.
* When results are trimmed, buckets are prioritised
* based on the volumes of documents they contain.
*
* @param {number} size Optional. The maximum number of geohex
* buckets to return (defaults to 10,000).
* @returns {GeoHexGridAggregation} returns `this` so that calls can be chained
*/
size(size) {
this._aggsDef.size = size;
return this;
}
/**
* Determines how many geohex_grid the coordinating node
* will request from each shard.
*
* @param {number} shardSize Optional.
* @returns {GeoHexGridAggregation} returns `this` so that calls can be chained
*/
shardSize(shardSize) {
this._aggsDef.shard_size = shardSize;
return this;
}
}
module.exports = GeoHexGridAggregation;
================================================
FILE: src/aggregations/bucket-aggregations/geo-tile-grid-aggregation.js
================================================
'use strict';
const _ = require('../../_');
const {
GeoPoint,
util: { checkType, setDefault }
} = require('../../core');
const BucketAggregationBase = require('./bucket-aggregation-base');
const ES_REF_URL =
'https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-geotilegrid-aggregation.html';
/**
* A multi-bucket aggregation that works on geo_point fields and groups points
* into buckets that represent cells in a grid. The resulting grid can be sparse
* and only contains cells that have matching data. Each cell corresponds to a
* map tile as used by many online map sites. Each cell is labeled using a
* "{zoom}/{x}/{y}" format, where zoom is equal to the user-specified precision.
* [Elasticsearch reference](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-geotilegrid-aggregation.html)
*
* NOTE: This query was added in elasticsearch v7.0.
*
* @example
* const agg = esb.geoTileGridAggregation('large-grid', 'location').precision(8);
*
* @param {string} name The name which will be used to refer to this aggregation.
* @param {string=} field The field to aggregate on
*
* @extends BucketAggregationBase
*/
class GeoTileGridAggregation extends BucketAggregationBase {
// eslint-disable-next-line require-jsdoc
constructor(name, field) {
super(name, 'geotile_grid', field);
}
/**
* @override
* @throws {Error} This method cannot be called on GeoTileGridAggregation
*/
format() {
console.log(`Please refer ${ES_REF_URL}`);
throw new Error('format is not supported in GeoTileGridAggregation');
}
/**
* @override
* @throws {Error} This method cannot be called on GeoTileGridAggregation
*/
script() {
console.log(`Please refer ${ES_REF_URL}`);
throw new Error('script is not supported in GeoTileGridAggregation');
}
/**
* The integer zoom of the key used to define cells/buckets in the results.
* Defaults to 7.
*
* @param {number} precision Precision can be between 0 and 29
* @returns {GeoTileGridAggregation} returns `this` so that calls can be chained
* @throws {Error} If precision is not between 0 and 29.
*/
precision(precision) {
if (_.isNil(precision) || precision < 0 || precision > 29) {
throw new Error('`precision` can only be value from 0 to 29.');
}
this._aggsDef.precision = precision;
return this;
}
/**
* Sets the maximum number of geotile buckets to return.
* When results are trimmed, buckets are prioritised
* based on the volumes of documents they contain.
*
* @param {number} size Optional. The maximum number of geotile
* buckets to return (defaults to 10,000).
* @returns {GeoTileGridAggregation} returns `this` so that calls can be chained
*/
size(size) {
this._aggsDef.size = size;
return this;
}
/**
* Determines how many geotile_grid buckets the coordinating node
* will request from each shard. To allow for more accurate counting of the
* top cells returned in the final result the aggregation defaults to
* returning `max(10,(size x number-of-shards))` buckets from each shard.
* If this heuristic is undesirable, the number considered from each shard
* can be over-ridden using this parameter.
*
* @param {number} shardSize Optional.
* @returns {GeoTileGridAggregation} returns `this` so that calls can be chained
*/
shardSize(shardSize) {
this._aggsDef.shard_size = shardSize;
return this;
}
/**
* Sets the top left coordinate for the bounding box used to filter the
* points in the bucket.
*
* @param {GeoPoint} point A valid `GeoPoint`
* @returns {GeoTileGridAggregation} returns `this` so that calls can be chained.
*/
topLeft(point) {
checkType(point, GeoPoint);
setDefault(this._aggsDef, 'bounds', {});
this._aggsDef.bounds.top_left = point;
return this;
}
/**
* Sets the bottom right coordinate for the bounding box used to filter the
* points in the bucket.
*
* @param {GeoPoint} point A valid `GeoPoint`
* @returns {GeoTileGridAggregation} returns `this` so that calls can be chained.
*/
bottomRight(point) {
checkType(point, GeoPoint);
setDefault(this._aggsDef, 'bounds', {});
this._aggsDef.bounds.bottom_right = point;
return this;
}
/**
* Sets the top right coordinate for the bounding box used to filter the
* points in the bucket.
*
* @param {GeoPoint} point A valid `GeoPoint`
* @returns {GeoTileGridAggregation} returns `this` so that calls can be chained.
*/
topRight(point) {
checkType(point, GeoPoint);
setDefault(this._aggsDef, 'bounds', {});
this._aggsDef.bounds.top_right = point;
return this;
}
/**
* Sets the bottom left coordinate for the bounding box used to filter the
* points in the bucket.
*
* @param {GeoPoint} point A valid `GeoPoint`
* @returns {GeoTileGridAggregation} returns `this` so that calls can be chained.
*/
bottomLeft(point) {
checkType(point, GeoPoint);
setDefault(this._aggsDef, 'bounds', {});
this._aggsDef.bounds.bottom_left = point;
return this;
}
/**
* Sets value for top of the bounding box.
*
* @param {number} val
* @returns {GeoTileGridAggregation} returns `this` so that calls can be chained.
*/
top(val) {
setDefault(this._aggsDef, 'bounds', {});
this._aggsDef.bounds.top = val;
return this;
}
/**
* Sets value for left of the bounding box.
*
* @param {number} val
* @returns {GeoTileGridAggregation} returns `this` so that calls can be chained.
*/
left(val) {
setDefault(this._aggsDef, 'bounds', {});
this._aggsDef.bounds.left = val;
return this;
}
/**
* Sets value for bottom of the bounding box.
*
* @param {number} val
* @returns {GeoTileGridAggregation} returns `this` so that calls can be chained.
*/
bottom(val) {
setDefault(this._aggsDef, 'bounds', {});
this._aggsDef.bounds.bottom = val;
return this;
}
/**
* Sets value for right of the bounding box.
*
* @param {number} val
* @returns {GeoTileGridAggregation} returns `this` so that calls can be chained.
*/
right(val) {
setDefault(this._aggsDef, 'bounds', {});
this._aggsDef.bounds.right = val;
return this;
}
}
module.exports = GeoTileGridAggregation;
================================================
FILE: src/aggregations/bucket-aggregations/global-aggregation.js
================================================
'use strict';
const BucketAggregationBase = require('./bucket-aggregation-base');
const ES_REF_URL =
'https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-global-aggregation.html';
/**
* Defines a single bucket of all the documents within the search execution
* context. This context is defined by the indices and the document types you’re
* searching on, but is not influenced by the search query itself.
*
* [Elasticsearch reference](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-global-aggregation.html)
*
* @example
* const reqBody = esb.requestBodySearch()
* .query(esb.matchQuery('type', 't-shirt'))
* .agg(
* esb.globalAggregation('all_products').agg(
* esb.avgAggregation('avg_price', 'price')
* )
* )
* .agg(esb.avgAggregation('t_shirts', 'price'));
*
* @param {string} name The name which will be used to refer to this aggregation.
*
* @extends BucketAggregationBase
*/
class GlobalAggregation extends BucketAggregationBase {
// eslint-disable-next-line require-jsdoc
constructor(name) {
super(name, 'global');
}
/**
* @override
* @throws {Error} This method cannot be called on GlobalAggregation
*/
field() {
console.log(`Please refer ${ES_REF_URL}`);
throw new Error('field is not supported in GlobalAggregation');
}
/**
* @override
* @throws {Error} This method cannot be called on GlobalAggregation
*/
script() {
console.log(`Please refer ${ES_REF_URL}`);
throw new Error('script is not supported in GlobalAggregation');
}
}
module.exports = GlobalAggregation;
================================================
FILE: src/aggregations/bucket-aggregations/histogram-aggregation-base.js
================================================
'use strict';
const _ = require('../../_');
const {
util: { invalidParam }
} = require('../../core');
const BucketAggregationBase = require('./bucket-aggregation-base');
const invalidDirectionParam = invalidParam('', 'direction', "'asc' or 'desc'");
/**
* The `HistogramAggregationBase` provides support for common options used across
* various histogram `Aggregation` implementations like Histogram Aggregation,
* Date Histogram aggregation.
*
* **NOTE:** Instantiating this directly should not be required.
* However, if you wish to add a custom implementation for whatever reason,
* this class could be extended.
*
* @param {string} name The name which will be used to refer to this aggregation.
* @param {string} aggType Type of aggregation
* @param {string=} field The field to aggregate on
* @param {string|number=} interval Interval to generate histogram over.
*
* @extends BucketAggregationBase
*/
class HistogramAggregationBase extends BucketAggregationBase {
// eslint-disable-next-line require-jsdoc
constructor(name, aggType, field, interval) {
super(name, aggType, field);
if (!_.isNil(interval)) this._aggsDef.interval = interval;
}
/**
* Sets the histogram interval. Buckets are generated based on this interval value.
*
* @param {string} interval Interval to generate histogram over.
* For date histograms, available expressions for interval:
* year, quarter, month, week, day, hour, minute, second
* @returns {HistogramAggregationBase} returns `this` so that calls can be chained
*/
interval(interval) {
this._aggsDef.interval = interval;
return this;
}
/**
* Sets the format expression for `key_as_string` in response buckets.
* If no format is specified, then it will use the first format specified in the field mapping.
*
* @example
* const agg = esb.dateHistogramAggregation(
* 'sales_over_time',
* 'date',
* '1M'
* ).format('yyyy-MM-dd');
*
* @param {string} fmt Format mask to apply on aggregation response. Example: ####.00.
* For Date Histograms, supports expressive [date format pattern](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-daterange-aggregation.html#date-format-pattern)
* @returns {HistogramAggregationBase} returns `this` so that calls can be chained
*/
format(fmt) {
this._aggsDef.format = fmt;
return this;
}
/**
* The offset parameter is used to change the start value of each bucket
* by the specified positive (+) or negative offset (-).
* Negative offset is not applicable on HistogramAggregation.
* In case of DateHistogramAggregation, duration can be
* a value such as 1h for an hour, or 1d for a day.
*
* @example
* const agg = esb.dateHistogramAggregation('by_day', 'date', 'day').offset('6h');
*
* @param {string} offset Time or bucket key offset for bucketing.
* @returns {HistogramAggregationBase} returns `this` so that calls can be chained
*/
offset(offset) {
this._aggsDef.offset = offset;
return this;
}
/**
* Sets the ordering for buckets
*
* @example
* const agg = esb.histogramAggregation('prices', 'price', 50)
* .order('_count', 'desc');
*
* @example
* const agg = esb.histogramAggregation('prices', 'price', 50)
* .order('promoted_products>rating_stats.avg', 'desc')
* .agg(
* esb.filterAggregation('promoted_products')
* .filter(esb.termQuery('promoted', 'true'))
* .agg(esb.statsAggregation('rating_stats', 'rating'))
* );
*
* @param {string} key
* @param {string} direction `asc` or `desc`
* @returns {HistogramAggregationBase} returns `this` so that calls can be chained
*/
order(key, direction = 'desc') {
if (_.isNil(direction)) invalidDirectionParam(direction);
const directionLower = direction.toLowerCase();
if (directionLower !== 'asc' && directionLower !== 'desc') {
invalidDirectionParam(direction);
}
if (_.has(this._aggsDef, 'order')) {
if (!Array.isArray(this._aggsDef.order)) {
this._aggsDef.order = [this._aggsDef.order];
}
this._aggsDef.order.push({ [key]: directionLower });
} else {
this._aggsDef.order = { [key]: directionLower };
}
return this;
}
/**
* Sets the minimum number of matching documents in range to return the bucket.
*
* @example
* const agg = esb.histogramAggregation('prices', 'price', 50).minDocCount(1);
*
* @param {number} minDocCnt Integer value for minimum number of documents
* required to return bucket in response
* @returns {HistogramAggregationBase} returns `this` so that calls can be chained
*/
minDocCount(minDocCnt) {
this._aggsDef.min_doc_count = minDocCnt;
return this;
}
/**
* Set's the range/bounds for the histogram aggregation.
* Useful when you want to include buckets that might be
* outside the bounds of indexed documents.
*
* @example
* const agg = esb.histogramAggregation('prices', 'price', 50).extendedBounds(0, 500);
*
* @param {number|string} min Start bound / minimum bound value
* For histogram aggregation, Integer value can be used.
* For Date histogram, date expression can be used.
* Available expressions for interval:
* year, quarter, month, week, day, hour, minute, second
* @param {number|string} max End bound / maximum bound value
* For histogram aggregation, Integer value can be used.
* For Date histogram, date expression can be used.
* Available expressions for interval:
* year, quarter, month, week, day, hour, minute, second
* @returns {HistogramAggregationBase} returns `this` so that calls can be chained
*/
extendedBounds(min, max) {
this._aggsDef.extended_bounds = { min, max };
return this;
}
/**
* Set's the range/bounds for the histogram aggregation.
* Useful when you want to limit the range of buckets in the histogram.
* It is particularly useful in the case of open data ranges that can result in a very large number of buckets.
* NOTE: Only available in Elasticsearch v7.10.0+
*
* @example
* const agg = esb.histogramAggregation('prices', 'price', 50).hardBounds(0, 500);
*
* @param {number|string} min Start bound / minimum bound value
* For histogram aggregation, Integer value can be used.
* For Date histogram, date expression can be used.
* Available expressions for interval:
* year, quarter, month, week, day, hour, minute, second
* @param {number|string} max End bound / maximum bound value
* For histogram aggregation, Integer value can be used.
* For Date histogram, date expression can be used.
* Available expressions for interval:
* year, quarter, month, week, day, hour, minute, second
* @returns {HistogramAggregationBase} returns `this` so that calls can be chained
*/
hardBounds(min, max) {
this._aggsDef.hard_bounds = { min, max };
return this;
}
/**
* Sets the missing parameter which defines how documents
* that are missing a value should be treated.
*
* @example
* const agg = esb.histogramAggregation('quantity', 'quantity', 10).missing(0);
*
* @param {string} value
* @returns {HistogramAggregationBase} returns `this` so that calls can be chained
*/
missing(value) {
this._aggsDef.missing = value;
return this;
}
/**
* Enable the response to be returned as a keyed object where the key is the
* bucket interval.
*
* @example
* const agg = esb.dateHistogramAggregation('sales_over_time', 'date', '1M')
* .keyed(true)
* .format('yyyy-MM-dd');
*
* @param {boolean} keyed To enable keyed response or not.
* @returns {HistogramAggregationBase} returns `this` so that calls can be chained
*/
keyed(keyed) {
this._aggsDef.keyed = keyed;
return this;
}
}
module.exports = HistogramAggregationBase;
================================================
FILE: src/aggregations/bucket-aggregations/histogram-aggregation.js
================================================
'use strict';
const HistogramAggregationBase = require('./histogram-aggregation-base');
/**
* A multi-bucket values source based aggregation that can be applied on
* numeric values extracted from the documents. It dynamically builds fixed
* size (a.k.a. interval) buckets over the values.
*
* [Elasticsearch reference](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-histogram-aggregation.html)
*
* @param {string} name The name which will be used to refer to this aggregation.
* @param {string=} field The field to aggregate on
* @param {number=} interval Interval to generate histogram over.
*
* @example
* const agg = esb.histogramAggregation('prices', 'price', 50);
*
* @example
* const agg = esb.histogramAggregation('prices', 'price', 50).minDocCount(1);
*
* @example
* const agg = esb.histogramAggregation('prices', 'price', 50)
* .extendedBounds(0, 500);
*
* @example
* const agg = esb.histogramAggregation('quantity', 'quantity', 10).missing(0);
*
* @extends HistogramAggregationBase
*/
class HistogramAggregation extends HistogramAggregationBase {
// eslint-disable-next-line require-jsdoc
constructor(name, field, interval) {
super(name, 'histogram', field, interval);
}
}
module.exports = HistogramAggregation;
================================================
FILE: src/aggregations/bucket-aggregations/index.js
================================================
'use strict';
exports.BucketAggregationBase = require('./bucket-aggregation-base');
exports.HistogramAggregationBase = require('./histogram-aggregation-base');
exports.RangeAggregationBase = require('./range-aggregation-base');
exports.TermsAggregationBase = require('./terms-aggregation-base');
exports.SignificantAggregationBase = require('./significant-aggregation-base');
exports.AdjacencyMatrixAggregation = require('./adjacency-matrix-aggregation');
exports.ChildrenAggregation = require('./children-aggregation');
exports.CompositeAggregation = require('./composite-aggregation');
exports.DateHistogramAggregation = require('./date-histogram-aggregation');
exports.AutoDateHistogramAggregation = require('./auto-date-histogram-aggregation');
exports.VariableWidthHistogramAggregation = require('./variable-width-histogram-aggregation');
exports.DateRangeAggregation = require('./date-range-aggregation');
exports.DiversifiedSamplerAggregation = require('./diversified-sampler-aggregation');
exports.FilterAggregation = require('./filter-aggregation');
exports.FiltersAggregation = require('./filters-aggregation');
exports.GeoDistanceAggregation = require('./geo-distance-aggregation');
exports.GeoHashGridAggregation = require('./geo-hash-grid-aggregation');
exports.GeoHexGridAggregation = require('./geo-hex-grid-aggregation');
exports.GeoTileGridAggregation = require('./geo-tile-grid-aggregation');
exports.GlobalAggregation = require('./global-aggregation');
exports.HistogramAggregation = require('./histogram-aggregation');
exports.IpRangeAggregation = require('./ip-range-aggregation');
exports.MissingAggregation = require('./missing-aggregation');
exports.NestedAggregation = require('./nested-aggregation');
exports.ParentAggregation = require('./parent-aggregation');
exports.RangeAggregation = require('./range-aggregation');
exports.RareTermsAggregation = require('./rare-terms-aggregation');
exports.ReverseNestedAggregation = require('./reverse-nested-aggregation');
exports.SamplerAggregation = require('./sampler-aggregation');
exports.SignificantTermsAggregation = require('./significant-terms-aggregation');
exports.SignificantTextAggregation = require('./significant-text-aggregation');
exports.TermsAggregation = require('./terms-aggregation');
================================================
FILE: src/aggregations/bucket-aggregations/ip-range-aggregation.js
================================================
'use strict';
const RangeAggregationBase = require('./range-aggregation-base');
const ES_REF_URL =
'https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-iprange-aggregation.html';
/**
* Dedicated range aggregation for IP typed fields.
*
* [Elasticsearch reference](https://www.elastic.co/guide/en/elasticsearch/reference/5current/search-aggregations-bucket-iprange-aggregation.html)
*
* @example
* const agg = esb.ipRangeAggregation('ip_ranges', 'ip').ranges([
* { to: '10.0.0.5' },
* { from: '10.0.0.5' }
* ]);
*
* @example
* const agg = esb.ipRangeAggregation('ip_ranges', 'ip').ranges([
* { mask: '10.0.0.0/25' },
* { mask: '10.0.0.127/25' }
* ]);
*
* @param {string} name The name which will be used to refer to this aggregation.
* @param {string=} field The field to aggregate on
*
* @extends RangeAggregationBase
*/
class IpRangeAggregation extends RangeAggregationBase {
// eslint-disable-next-line require-jsdoc
constructor(name, field) {
super(name, 'ip_range', field);
// Variable name is misleading. Only one of these needs to be present.
this._rangeRequiredKeys = ['from', 'to', 'mask'];
}
/**
* @override
* @throws {Error} This method cannot be called on IpRangeAggregation
*/
format() {
console.log(`Please refer ${ES_REF_URL}`);
throw new Error('format is not supported in IpRangeAggregation');
}
}
module.exports = IpRangeAggregation;
================================================
FILE: src/aggregations/bucket-aggregations/missing-aggregation.js
================================================
'use strict';
const BucketAggregationBase = require('./bucket-aggregation-base');
const ES_REF_URL =
'https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-missing-aggregation.html';
/**
* A field data based single bucket aggregation, that creates a bucket of all
* documents in the current document set context that are missing a field value
* (effectively, missing a field or having the configured NULL value set).
*
* [Elasticsearch reference](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-missing-aggregation.html)
*
* @example
* const agg = esb.missingAggregation('products_without_a_price', 'price');
*
* @param {string} name The name which will be used to refer to this aggregation.
* @param {string=} field The field to aggregate on
*
* @extends BucketAggregationBase
*/
class MissingAggregation extends BucketAggregationBase {
// eslint-disable-next-line require-jsdoc
constructor(name, field) {
super(name, 'missing', field);
}
/**
* @override
* @throws {Error} This method cannot be called on MissingAggregation
*/
script() {
console.log(`Please refer ${ES_REF_URL}`);
throw new Error('script is not supported in MissingAggregation');
}
}
module.exports = MissingAggregation;
================================================
FILE: src/aggregations/bucket-aggregations/nested-aggregation.js
================================================
'use strict';
const _ = require('../../_');
const BucketAggregationBase = require('./bucket-aggregation-base');
const ES_REF_URL =
'https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-nested-aggregation.html';
/**
* A special single bucket aggregation that enables aggregating nested
* documents.
*
* [Elasticsearch reference](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-nested-aggregation.html)
*
* @example
* const reqBody = esb.requestBodySearch()
* .query(esb.matchQuery('name', 'led tv'))
* .agg(
* esb.nestedAggregation('resellers', 'resellers').agg(
* esb.minAggregation('min_price', 'resellers.price')
* )
* );
*
* @param {string} name The name which will be used to refer to this aggregation.
* @param {string=} path `path` of the nested document
*
* @extends BucketAggregationBase
*/
class NestedAggregation extends BucketAggregationBase {
// eslint-disable-next-line require-jsdoc
constructor(name, path) {
super(name, 'nested');
if (!_.isNil(path)) this._aggsDef.path = path;
}
/**
* @override
* @throws {Error} This method cannot be called on NestedAggregation
*/
field() {
console.log(`Please refer ${ES_REF_URL}`);
throw new Error('field is not supported in NestedAggregation');
}
/**
* @override
* @throws {Error} This method cannot be called on NestedAggregation
*/
script() {
console.log(`Please refer ${ES_REF_URL}`);
throw new Error('script is not supported in NestedAggregation');
}
/**
* Sets the nested path
*
* @param {string} path `path` of the nested document
* @returns {NestedAggregation} returns `this` so that calls can be chained
*/
path(path) {
this._aggsDef.path = path;
return this;
}
}
module.exports = NestedAggregation;
================================================
FILE: src/aggregations/bucket-aggregations/parent-aggregation.js
================================================
'use strict';
const _ = require('../../_');
const BucketAggregationBase = require('./bucket-aggregation-base');
const ES_REF_URL =
'https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-parent-aggregation.html';
/**
* A special single bucket aggregation that enables aggregating
* from buckets on child document types to buckets on parent documents.
*
* This aggregation relies on the `_parent` field in the mapping.
*
* [Elasticsearch reference](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-parent-aggregation.html)
*
* @example
* const reqBody = esb.requestBodySearch()
* .agg(
* esb.termsAggregation('top-names', 'owner.display_name.keyword')
* .size(10)
* .agg(
* esb.parentAggregation('to-questions')
* .type('answer')
* .agg(
* esb.termsAggregation(
* 'top-tags',
* 'tags.keyword'
* ).size(10)
* )
* )
* )
* .size(0);
*
* @param {string} name The name which will be used to refer to this aggregation.
* @param {string=} type The type of the child document.
*
* @extends BucketAggregationBase
*/
class ParentAggregation extends BucketAggregationBase {
// eslint-disable-next-line require-jsdoc
constructor(name, type) {
super(name, 'parent');
if (!_.isNil(type)) this.type(type);
}
/**
* @override
* @throws {Error} This method cannot be called on ParentAggregation
*/
field() {
console.log(`Please refer ${ES_REF_URL}`);
throw new Error('field is not supported in ParentAggregation');
}
/**
* @override
* @throws {Error} This method cannot be called on ParentAggregation
*/
script() {
console.log(`Please refer ${ES_REF_URL}`);
throw new Error('script is not supported in ParentAggregation');
}
/**
* Sets the child type/mapping for aggregation.
*
* @param {string} type The child type that the buckets in the parent space should be mapped to.
* @returns {ParentAggregation} returns `this` so that calls can be chained
*/
type(type) {
this._aggsDef.type = type;
return this;
}
}
module.exports = ParentAggregation;
================================================
FILE: src/aggregations/bucket-aggregations/range-aggregation-base.js
================================================
'use strict';
const _ = require('../../_');
const {
util: { checkType }
} = require('../../core');
const BucketAggregationBase = require('./bucket-aggregation-base');
const hasOwnProp = Object.prototype.hasOwnProperty;
/**
* The `RangeAggregationBase` provides support for common options used across
* various range `Aggregation` implementations like Range Aggregation and
* Date Range aggregation.
*
* **NOTE:** Instantiating this directly should not be required.
* However, if you wish to add a custom implementation for whatever reason,
* this class could be extended.
*
* @param {string} name The name which will be used to refer to this aggregation.
* @param {string} aggType Type of aggregation
* @param {string=} field The field to aggregate on
*
* @extends BucketAggregationBase
*/
class RangeAggregationBase extends BucketAggregationBase {
// eslint-disable-next-line require-jsdoc
constructor(name, aggType, field) {
super(name, aggType, field);
// Variable name is misleading. Only one of these needs to be present.
this._rangeRequiredKeys = ['from', 'to'];
this._aggsDef.ranges = [];
}
/**
* Sets the format expression for `key_as_string` in response buckets.
* If no format is specified, then it will use the format specified in the field mapping.
*
* @param {string} fmt Supports expressive [date format pattern](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-daterange-aggregation.html#date-format-pattern) for Date Histograms
* @returns {RangeAggregationBase} returns `this` so that calls can be chained
*/
format(fmt) {
this._aggsDef.format = fmt;
return this;
}
/**
* Adds a range to the list of existing range expressions.
*
* @param {Object} range Range to aggregate over. Valid keys are `from`, `to` and `key`
* @returns {RangeAggregationBase} returns `this` so that calls can be chained
*
* @throws {TypeError} If `range` is not an instance of object
* @throws {Error} If none of the required keys,
* `from`, `to` or `mask`(for IP range) is passed
*/
range(range) {
checkType(range, Object);
if (!this._rangeRequiredKeys.some(hasOwnProp, range)) {
throw new Error(
`Invalid Range! Range must have at least one of ${this._rangeRequiredKeys}`
);
}
this._aggsDef.ranges.push(range);
return this;
}
/**
* Adds the list of ranges to the list of existing range expressions.
*
* @param {Array<Object>} ranges Ranges to aggregate over.
* Each item must be an object with keys `from`, `to` and `key`.
* @returns {RangeAggregationBase} returns `this` so that calls can be chained
*
* @throws {TypeError} If `ranges` is not an instance of an array or
* and item in the array is not an instance of object
* @throws {Error} If none of the required keys,
* `from`, `to` or `mask`(for IP range) is passed
*/
ranges(ranges) {
checkType(ranges, Array);
ranges.forEach(range => this.range(range));
return this;
}
/**
* Sets the missing parameter ehich defines how documents
* that are missing a value should be treated.
*
* @param {string} value
* @returns {RangeAggregationBase} returns `this` so that calls can be chained
*/
missing(value) {
this._aggsDef.missing = value;
return this;
}
/**
* Enable the response to be returned as a keyed object where the key is the
* bucket interval.
*
* @example
* const agg = esb.dateRangeAggregation('range', 'date')
* .format('MM-yyy')
* .ranges([{ to: 'now-10M/M' }, { from: 'now-10M/M' }])
* .keyed(true);
*
* @example
* const agg = esb.geoDistanceAggregation('rings_around_amsterdam', 'location')
* .origin(esb.geoPoint().string('52.3760, 4.894'))
* .ranges([
* { to: 100000, key: 'first_ring' },
* { from: 100000, to: 300000, key: 'second_ring' },
* { from: 300000, key: 'third_ring' }
* ])
* .keyed(true);
*
* @param {boolean} keyed To enable keyed response or not.
* @returns {RangeAggregationBase} returns `this` so that calls can be chained
*/
keyed(keyed) {
this._aggsDef.keyed = keyed;
return this;
}
/**
* Override default `toJSON` to return DSL representation for the `aggregation` query.
*
* @override
* @returns {Object} returns an Object which maps to the elasticsearch query DSL
*/
toJSON() {
if (_.isEmpty(this._aggsDef.ranges)) {
throw new Error('`ranges` cannot be empty.');
}
return super.toJSON();
}
}
module.exports = RangeAggregationBase;
================================================
FILE: src/aggregations/bucket-aggregations/range-aggregation.js
================================================
'use strict';
const RangeAggregationBase = require('./range-aggregation-base');
/**
* A multi-bucket value source based aggregation that enables the user to
* define a set of ranges - each representing a bucket. During the aggregation
* process, the values extracted from each document will be checked against each
* bucket range and "bucket" the relevant/matching document.
*
* Note that this aggregration includes the from value and excludes the to
* value for each range.
*
* [Elasticsearch reference](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-range-aggregation.html)
*
* @example
* const agg = esb.rangeAggregation('price_ranges', 'price').ranges([
* { to: 50 },
* { from: 50, to: 100 },
* { from: 100 }
* ]);
*
* @example
* const agg = esb.rangeAggregation('price_ranges')
* .script(esb.script('inline', "doc['price'].value").lang('painless'))
* .ranges([{ to: 50 }, { from: 50, to: 100 }, { from: 100 }]);
*
* @example
* // Value script for on-the-fly conversion before aggregation
* const agg = esb.rangeAggregation('price_ranges', 'price')
* .script(
* esb.script('inline', '_value * params.conversion_rate')
* .lang('painless')
* .params({ conversion_rate: 0.8 })
* )
* .ranges([{ to: 50 }, { from: 50, to: 100 }, { from: 100 }]);
*
* @example
* // Compute statistics over the prices in each price range
* const agg = esb.rangeAggregation('price_ranges', 'price')
* .ranges([{ to: 50 }, { from: 50, to: 100 }, { from: 100 }])
* // Passing price to Stats Aggregation is optional(same value source)
* .agg(esb.statsAggregation('price_stats', 'price'));
*
* @param {string} name The name which will be used to refer to this aggregation.
* @param {string=} field The field to aggregate on
*
* @extends RangeAggregationBase
*/
class RangeAggregation extends RangeAggregationBase {
// eslint-disable-next-line require-jsdoc
constructor(name, field) {
super(name, 'range', field);
}
}
module.exports = RangeAggregation;
================================================
FILE: src/aggregations/bucket-aggregations/rare-terms-aggregation.js
================================================
'use strict';
const _ = require('../../_');
const BucketAggregationBase = require('./bucket-aggregation-base');
const ES_REF_URL =
'https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-rare-terms-aggregation.html';
/**
* A multi-bucket value source based aggregation which finds
* "rare" terms — terms that are at the long-tail of the
* distribution and are not frequent. Conceptually, this is like
* a terms aggregation that is sorted by `_count` ascending.
* As noted in the terms aggregation docs, actually ordering
* a `terms` agg by count ascending has unbounded error.
* Instead, you should use the `rare_terms` aggregation
*
* [Elasticsearch reference](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-rare-terms-aggregation.html)
*
* NOTE: Only available in Elasticsearch 7.3.0+.
*
* @example
* const agg = esb.rareTermsAggregation('genres', 'genre');
*
* @param {string} name The name which will be used to refer to this aggregation.
* @param {string} field The field we wish to find rare terms in
*
* @extends BucketAggregationBase
*/
class RareTermsAggregation extends BucketAggregationBase {
// eslint-disable-next-line require-jsdoc
constructor(name, field) {
super(name, 'rare_terms', field);
}
/**
* Sets the maximum number of documents a term should appear in.
*
* @example
* const agg = esb.rareTermsAggregation('genres', 'genre').maxDocCount(2);
*
* @param {number} maxDocCnt Integer value for maximum number of documents a term should appear in.
* Max doc count can be between 1 and 100.
* @returns {RareTermsAggregation} returns `this` so that calls can be chained
*/
maxDocCount(maxDocCnt) {
if (_.isNil(maxDocCnt) || maxDocCnt < 1 || maxDocCnt > 100) {
throw new Error('`maxDocCount` can only be value from 1 to 100.');
}
this._aggsDef.max_doc_count = maxDocCnt;
return this;
}
/**
* Sets the precision of the internal CuckooFilters. Smaller precision
* leads to better approximation, but higher memory usage.
* Cannot be smaller than 0.00001
*
* @example
* const agg = esb.rareTermsAggregation('genres', 'genre').precision(0.001);
*
* @param {number} precision Float value for precision of the internal CuckooFilters. Default is 0.01
* @returns {RareTermsAggregation} returns `this` so that calls can be chained
*/
precision(precision) {
if (precision < 0.00001) {
throw new Error('`precision` must be greater than 0.00001.');
}
this._aggsDef.precision = precision;
return this;
}
/**
* Sets terms that should be included in the aggregation
*
* @example
* const agg = esb.rareTermsAggregation('genres', 'genre').include('swi*');
*
* @param {string} include Regular expression that will determine what values
* are "allowed" to be aggregated
* @returns {RareTermsAggregation} returns `this` so that calls can be chained
*/
include(include) {
this._aggsDef.include = include;
return this;
}
/**
* Sets terms that should be excluded from the aggregation
*
* @example
* const agg = esb.rareTermsAggregation('genres', 'genre').exclude('electro*');
*
* @param {string} exclude Regular expression that will determine what values
* should not be aggregated
* @returns {RareTermsAggregation} returns `this` so that calls can be chained
*/
exclude(exclude) {
this._aggsDef.exclude = exclude;
return this;
}
/**
* Sets the missing parameter which defines how documents
* that are missing a value should be treated.
*
* @param {string} value
* @returns {RareTermsAggregation} returns `this` so that calls can be chained
*/
missing(value) {
this._aggsDef.missing = value;
return this;
}
/**
* @override
* @throws {Error} This method cannot be called on RareTermsAggregation
*/
script() {
console.log(`Please refer ${ES_REF_URL}`);
throw new Error('script is not supported in RareTermsAggregation');
}
}
module.exports = RareTermsAggregation;
================================================
FILE: src/aggregations/bucket-aggregations/reverse-nested-aggregation.js
================================================
'use strict';
const _ = require('../../_');
const BucketAggregationBase = require('./bucket-aggregation-base');
const ES_REF_URL =
'https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-reverse-nested-aggregation.html';
/**
* A special single bucket aggregation that enables aggregating
* on parent docs from nested documents. Effectively this
* aggregation can break out of the nested block structure and
* link to other nested structures or the root document,
* which allows nesting other aggregations that aren’t part of
* the nested object in a nested aggregation.
*
* The `reverse_nested` aggregation must be defined inside a nested aggregation.
*
* [Elasticsearch reference](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-reverse-nested-aggregation.html)
*
* @example
* const reqBody = esb.requestBodySearch()
* .query(esb.matchQuery('name', 'led tv'))
* .agg(
* esb.nestedAggregation('comments', 'comments').agg(
* esb.termsAggregation('top_usernames', 'comments.username').agg(
* esb.reverseNestedAggregation('comment_to_issue').agg(
* esb.termsAggregation('top_tags_per_comment', 'tags')
* )
* )
* )
* );
*
* @param {string} name The name which will be used to refer to this aggregation.
* @param {string=} path Defines to what nested object field should be joined back.
* The default is empty, which means that it joins back to the root / main document
* level.
*
* @extends BucketAggregationBase
*/
class ReverseNestedAggregation extends BucketAggregationBase {
// eslint-disable-next-line require-jsdoc
constructor(name, path) {
super(name, 'reverse_nested');
if (!_.isNil(path)) this._aggsDef.path = path;
}
/**
* @override
* @throws {Error} This method cannot be called on ReverseNestedAggregation
*/
field() {
console.log(`Please refer ${ES_REF_URL}`);
throw new Error('field is not supported in ReverseNestedAggregation');
}
/**
* @override
* @throws {Error} This method cannot be called on ReverseNestedAggregation
*/
script() {
console.log(`Please refer ${ES_REF_URL}`);
throw new Error('script is not supported in ReverseNestedAggregation');
}
/**
* Sets the level to join back for subsequent aggregations in a multiple
* layered nested object types
*
* @param {string} path Defines to what nested object field should be joined back.
* The default is empty, which means that it joins back to the root / main document
* level.
* @returns {ReverseNestedAggregation} returns `this` so that calls can be chained
*/
path(path) {
this._aggsDef.path = path;
return this;
}
}
module.exports = ReverseNestedAggregation;
================================================
FILE: src/aggregations/bucket-aggregations/sampler-aggregation.js
================================================
'use strict';
const BucketAggregationBase = require('./bucket-aggregation-base');
const ES_REF_URL =
'https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-sampler-aggregation.html';
/**
* A filtering aggregation used to limit any sub aggregations'
* processing to a sample of the top-scoring documents.
*
* [Elasticsearch reference](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-sampler-aggregation.html)
*
* @example
* const reqBody = esb.requestBodySearch()
* .query(esb.queryStringQuery('tags:kibana OR tags:javascript'))
* .agg(
* esb.samplerAggregation('sample')
* .shardSize(200)
* .agg(
* esb.significantTermsAggregation(
* 'keywords',
* 'tags'
* ).exclude(['kibana', 'javascript'])
* )
* );
*
* @param {string} name The name which will be used to refer to this aggregation.
* @param {string=} field The field to aggregate on
*
* @extends BucketAggregationBase
*/
class SamplerAggregation extends BucketAggregationBase {
// eslint-disable-next-line require-jsdoc
constructor(name) {
super(name, 'sampler');
}
/**
* @override
* @throws {Error} This method cannot be called on SamplerAggregation
*/
field() {
console.log(`Please refer ${ES_REF_URL}`);
throw new Error('field is not supported in SamplerAggregation');
}
/**
* @override
* @throws {Error} This method cannot be called on SamplerAggregation
*/
script() {
console.log(`Please refer ${ES_REF_URL}`);
throw new Error('script is not supported in SamplerAggregation');
}
/**
* The shard_size parameter limits how many top-scoring documents
* are collected in the sample processed on each shard. The default value is 100.
*
* @param {number} size Maximum number of documents to return from each shard(Integer)
* @returns {SamplerAggregation} returns `this` so that calls can be chained
*/
shardSize(size) {
this._aggsDef.shard_size = size;
return this;
}
}
module.exports = SamplerAggregation;
================================================
FILE: src/aggregations/bucket-aggregations/significant-aggregation-base.js
================================================
'use strict';
const {
Query,
Script,
util: { checkType }
} = require('../../core');
const TermsAggregationBase = require('./terms-aggregation-base');
/**
* The `SignificantAggregationBase` provides support for common options used
* in `SignificantTermsAggregation` and `SignificantTextAggregation`.
*
* **NOTE:** Instantiating this directly should not be required.
* However, if you wish to add a custom implementation for whatever reason,
* this class could be extended.
*
* @extends TermsAggregationBase
*/
class SignificantAggregationBase extends TermsAggregationBase {
/**
* Use JLH score as significance score.
*
* @returns {SignificantAggregationBase} returns `this` so that calls can be chained
*/
jlh() {
// I am guessing here
// Reference is not clear on usage
this._aggsDef.jlh = {};
return this;
}
/**
* Use `mutual_information` as significance score
*
* @param {boolean=} includeNegatives Default `true`. If set to `false`,
* filters out the terms that appear less often in the subset than in
* documents outside the subset
* @param {boolean=} backgroundIsSuperset `true`(default) if the documents in the bucket
* are also contained in the background. If instead you defined a custom background filter
* that represents a different set of documents that you want to compare to, pass `false`
* @returns {SignificantAggregationBase} returns `this` so that calls can be chained
*/
mutualInformation(includeNegatives = true, backgroundIsSuperset = true) {
this._aggsDef.mutual_information = {
include_negatives: includeNegatives,
background_is_superset: backgroundIsSuperset
};
return this;
}
/**
* Use `chi_square` as significance score
*
* @param {boolean} includeNegatives Default `true`. If set to `false`,
* filters out the terms that appear less often in the subset than in
* documents outside the subset
* @param {boolean} backgroundIsSuperset `true`(default) if the documents in the bucket
* are also contained in the background. If instead you defined a custom background filter
* that represents a different set of documents that you want to compare to, pass `false`
* @returns {SignificantAggregationBase} returns `this` so that calls can be chained
*/
chiSquare(includeNegatives = true, backgroundIsSuperset = true) {
this._aggsDef.chi_square = {
include_negatives: includeNegatives,
background_is_superset: backgroundIsSuperset
};
return this;
}
/**
* Sets `gnd`, google normalized score to be used as significance score.
*
* @param {boolean} backgroundIsSuperset `true`(default) if the documents in the bucket
* are also contained in the background. If instead you defined a custom background filter
* that represents a different set of documents that you want to compare to, pass `false`
* @returns {SignificantAggregationBase} returns `this` so that calls can be chained
*/
gnd(backgroundIsSuperset = true) {
this._aggsDef.gnd = {
background_is_superset: backgroundIsSuperset
};
return this;
}
/**
* Use a simple calculation of the number of documents in the foreground sample with a term
* divided by the number of documents in the background with the term. By default this
* produces a score greater than zero and less than one.
*
* @returns {SignificantAggregationBase} returns `this` so that calls can be chained
*/
percentage() {
this._aggsDef.percentage = {};
return this;
}
/**
* Sets script for customized score calculation.
*
* @param {Script} script
* @returns {SignificantAggregationBase} returns `this` so that calls can be chained
*/
scriptHeuristic(script) {
checkType(script, Script);
this._aggsDef.script_heuristic = { script };
return this;
}
/**
* Sets the `background_filter` to narrow the scope of statistical information
* for background term frequencies instead of using the entire index.
*
* @example
* const reqBody = esb.requestBodySearch()
* .query(esb.matchQuery('text', 'madrid'))
* .agg(
* esb.significantAggregationBase('tags', 'tag').backgroundFilter(
* esb.termQuery('text', 'spain')
* )
* );
*
* @param {Query} filterQuery Filter query
* @returns {SignificantAggregationBase} returns `this` so that calls can be chained
*/
backgroundFilter(filterQuery) {
checkType(filterQuery, Query);
this._aggsDef.background_filter = filterQuery;
return this;
}
/**
* @override
* @throws {Error} This method cannot be called on SignificantAggregationBase
*/
script() {
console.log(`Please refer ${this._refUrl}`);
throw new Error(`script is not supported in ${this.constructor.name}`);
}
}
module.exports = SignificantAggregationBase;
================================================
FILE: src/aggregations/bucket-aggregations/significant-terms-aggregation.js
================================================
'use strict';
const SignificantAggregationBase = require('./significant-aggregation-base');
const ES_REF_URL =
'https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-significantterms-aggregation.html';
/**
* An aggregation that returns interesting or unusual occurrences of terms in
* a set.
*
* [Elasticsearch reference](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-significantterms-aggregation.html)
*
* @example
* const reqBody = esb.requestBodySearch()
* .query(esb.termsQuery('force', 'British Transport Police'))
* .agg(
* esb.significantTermsAggregation(
* 'significantCrimeTypes',
* 'crime_type'
* )
* );
*
* @example
* // Use parent aggregation for segregated data analysis
* const agg = esb.termsAggregation('forces', 'force').agg(
* esb.significantTermsAggregation('significantCrimeTypes', 'crime_type')
* );
*
* @param {string} name The name which will be used to refer to this aggregation.
* @param {string=} field The field to aggregate on
*
* @extends SignificantAggregationBase
*/
class SignificantTermsAggregation extends SignificantAggregationBase {
// eslint-disable-next-line require-jsdoc
constructor(name, field) {
super(name, 'significant_terms', ES_REF_URL, field);
}
}
module.exports = SignificantTermsAggregation;
================================================
FILE: src/aggregations/bucket-aggregations/significant-text-aggregation.js
================================================
'use strict';
const {
util: { checkType }
} = require('../../core');
const SignificantAggregationBase = require('./significant-aggregation-base');
const ES_REF_URL =
'https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-significanttext-aggregation.html';
/**
* An aggregation that returns interesting or unusual occurrences of free-text
* terms in a set. It is like the `SignificantTermsAggregation` but differs in
* that:
* - It is specifically designed for use on type `text` fields
* - It does not require field data or doc-values
* - It re-analyzes text content on-the-fly meaning it can also filter
* duplicate sections of noisy text that otherwise tend to skew statistics.
*
* [Elasticsearch reference](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-significanttext-aggregation.html)
*
* NOTE: This query was added in elasticsearch v6.0.
*
* @example
* const reqBody = esb.requestBodySearch()
* .query(esb.matchQuery('content', 'Bird flu'))
* .agg(
* esb.samplerAggregation('my_sample')
* .shardSize(100)
* .agg(esb.significantTextAggregation('keywords', 'content'))
* );
*
* @param {string} name The name which will be used to refer to this aggregation.
* @param {string=} field The field to aggregate on
*
* @extends SignificantAggregationBase
*/
class SignificantTextAggregation extends SignificantAggregationBase {
// eslint-disable-next-line require-jsdoc
constructor(name, field) {
super(name, 'significant_text', ES_REF_URL, field);
}
/**
* Control if duplicate paragraphs of text should try be filtered from the
* statistical text analysis. Can improve results but slows down analysis.
* Default is `false`.
*
* @example
* const reqBody = esb.requestBodySearch()
* .query(esb.matchQuery('content', 'elasticsearch'))
* .agg(
* esb.samplerAggregation('sample')
* .shardSize(100)
* .agg(
* esb.significantTextAggregation('keywords', 'content')
* .filterDuplicateText(true)
* )
* );
*
* @param {boolean} enable
* @returns {SignificantTextAggregation} returns `this` so that calls can be chained
*/
filterDuplicateText(enable) {
this._aggsDef.filter_duplicate_text = enable;
return this;
}
/**
* Selects the fields to load from `_source` JSON and analyze. If none are
* specified, the indexed "fieldName" value is assumed to also be the name
* of the JSON field holding the value
*
* @example
* const reqBody = esb.requestBodySearch()
* .query(esb.matchQuery('custom_all', 'elasticsearch'))
* .agg(
* esb.significantTextAggregation('tags', 'custom_all')
* .sourceFields(['content', 'title'])
* );
*
* @param {Array<string>} srcFields Array of fields
* @returns {SignificantTextAggregation} returns `this` so that calls can be chained
*/
sourceFields(srcFields) {
checkType(srcFields, Array);
this._aggsDef.source_fields = srcFields;
return this;
}
/**
* @override
* @throws {Error} This method cannot be called on SignificantTextAggregation
*/
missing() {
console.log(`Please refer ${ES_REF_URL}`);
throw new Error(
'missing is not supported in SignificantTextAggregation'
);
}
/**
* @override
* @throws {Error} This method cannot be called on SignificantTextAggregation
*/
executionHint() {
console.log(`Please refer ${ES_REF_URL}`);
throw new Error(
'executionHint is not supported in SignificantTextAggregation'
);
}
}
module.exports = SignificantTextAggregation;
================================================
FILE: src/aggregations/bucket-aggregations/terms-aggregation-base.js
================================================
'use strict';
const _ = require('../../_');
const {
util: { invalidParam },
consts: { EXECUTION_HINT_SET }
} = require('../../core');
const BucketAggregationBase = require('./bucket-aggregation-base');
const invalidExecutionHintParam = invalidParam(
'',
'execution_hint',
EXECUTION_HINT_SET
);
/**
* The `TermsAggregationBase` provides support for common options used across
* various terms `Aggregation` implementations like Significant terms and
* Terms aggregation.
*
* **NOTE:** Instantiating this directly should not be required.
* However, if you wish to add a custom implementation for whatever reason,
* this class could be extended.
*
* @param {string} name The name which will be used to refer to this aggregation.
* @param {string} aggType Type of aggregation
* @param {string} refUrl Elasticsearch reference URL.
* @param {string=} field The field to aggregate on
*
* @extends BucketAggregationBase
*/
class TermsAggregationBase extends BucketAggregationBase {
// eslint-disable-next-line require-jsdoc
constructor(name, aggType, refUrl, field) {
super(name, aggType, field);
this._refUrl = refUrl;
}
/**
* Sets the format expression for `key_as_string` in response buckets.
* If no format is specified, then it will use the first format specified in the field mapping.
*
* @param {string} fmt Format mask to apply on aggregation response. Example: ####.00.
* @returns {TermsAggregationBase} returns `this` so that calls can be chained
*/
format(fmt) {
this._aggsDef.format = fmt;
return this;
}
/**
* Sets the minimum number of matching hits required to return the terms.
*
* @example
* const agg = esb.significantTermsAggregation('tags', 'tag').minDocCount(10);
*
* @param {number} minDocCnt Integer value for minimum number of documents
* required to return bucket in response
* @returns {TermsAggregationBase} returns `this` so that calls can be chained
*/
minDocCount(minDocCnt) {
this._aggsDef.min_doc_count = minDocCnt;
return this;
}
/**
* Sets the parameter which regulates the _certainty_ a shard has if the term
* should actually be added to the candidate list or not with respect to
* the `min_doc_count`.
* Terms will only be considered if their local shard frequency within
* the set is higher than the `shard_min_doc_count`.
*
* @param {number} minDocCnt Sets the `shard_min_doc_count` parameter. Default is 1
* and has no effect unless you explicitly set it.
* @returns {TermsAggregationBase} returns `this` so that calls can be chained
*/
shardMinDocCount(minDocCnt) {
this._aggsDef.shard_min_doc_count = minDocCnt;
return this;
}
/**
* Defines how many term buckets should be returned out of the overall terms list.
*
* @example
* const agg = esb.termsAggregation('products', 'product').size(5);
*
* @param {number} size
* @returns {TermsAggregationBase} returns `this` so that calls can be chained
*/
size(size) {
this._aggsDef.size = size;
return this;
}
/**
* Sets the `shard_size` parameter to control the volumes of candidate terms
* produced by each shard. For the default, -1, shard_size will be automatically
* estimated based on the number of shards and the size parameter.
*
* `shard_size` cannot be smaller than size (as it doesn’t make much sense).
* When it is, elasticsearch will override it and reset it to be equal to size.
*
* @param {number} size
* @returns {TermsAggregationBase} returns `this` so that calls can be chained
*/
shardSize(size) {
this._aggsDef.shard_size = size;
return this;
}
/**
* Sets the missing parameter which defines how documents
* that are missing a value should be treated.
*
* @param {string} value
* @returns {TermsAggregationBase} returns `this` so that calls can be chained
*/
missing(value) {
this._aggsDef.missing = value;
return this;
}
/**
* Filter the values for which buckets will be created.
*
* @example
* const agg = esb.termsAggregation('tags', 'tags')
* .include('.*sport.*')
* .exclude('water_.*');
*
* @example
* // Match on exact values
* const reqBody = esb.requestBodySearch()
* .agg(
* esb.termsAggregation('JapaneseCars', 'make').include([
* 'mazda',
* 'honda'
* ])
* )
* .agg(
* esb.termsAggregation('ActiveCarManufacturers', 'make').exclude([
* 'rover',
* 'jensen'
* ])
* );
*
* @param {RegExp|Array|string} clause Determine what values are "allowed" to be aggregated
* @returns {TermsAggregationBase} returns `this` so that calls can be chained
*/
include(clause) {
this._aggsDef.include = clause;
return this;
}
/**
* Filter the values for which buckets will be created.
*
* @example
* const agg = esb.termsAggregation('tags', 'tags')
* .include('.*sport.*')
* .exclude('water_.*');
*
* @example
* // Match on exact values
* const reqBody = esb.requestBodySearch()
* .agg(
* esb.termsAggregation('JapaneseCars', 'make').include([
* 'mazda',
* 'honda'
* ])
* )
* .agg(
* esb.termsAggregation('ActiveCarManufacturers', 'make').exclude([
* 'rover',
* 'jensen'
* ])
* );
*
* @param {RegExp|Array|string} clause Determine the values that should not be aggregated
* @returns {TermsAggregationBase} returns `this` so that calls can be chained
*/
exclude(clause) {
this._aggsDef.exclude = clause;
return this;
}
/**
* This setting can influence the management of the values used
* for de-duplication. Each option will hold up to shard_size
* values in memory while performing de-duplication but
* the type of value held can be controlled
*
* @example
* const agg = esb.significantTermsAggregation('tags', 'tag').executionHint('map');
*
* @example
* const agg = esb.termsAggregation('tags', 'tags').executionHint('map');
*
* @param {string} hint the possible values are `map`, `global_ordinals`,
* `global_ordinals_hash` and `global_ordinals_low_cardinality`
* @returns {TermsAggregationBase} returns `this` so that calls can be chained
* @throws {Error} If Execution Hint is outside the accepted set.
*/
executionHint(hint) {
if (_.isNil(hint)) invalidExecutionHintParam(hint, this._refUrl);
const hintLower = hint.toLowerCase();
if (!EXECUTION_HINT_SET.has(hintLower)) {
invalidExecutionHintParam(hint, this._refUrl);
}
this._aggsDef.execution_hint = hint;
return this;
}
}
module.exports = TermsAggregationBase;
================================================
FILE: src/aggregations/bucket-aggregations/terms-aggregation.js
================================================
'use strict';
const _ = require('../../_');
const {
util: { invalidParam }
} = require('../../core');
const TermsAggregationBase = require('./terms-aggregation-base');
const ES_REF_URL =
'https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html';
const invalidDirectionParam = invalidParam(
ES_REF_URL,
'direction',
"'asc' or 'desc'"
);
const invalidCollectModeParam = invalidParam(
ES_REF_URL,
'mode',
"'breadth_first' or 'depth_first'"
);
/**
* A multi-bucket value source based aggregation where buckets are dynamically
* built - one per unique value.
*
* [Elasticsearch reference](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html)
*
* @example
* const agg = esb.termsAggregation('genres', 'genre');
*
* @param {string} name The name which will be used to refer to this aggregation.
* @param {string=} field The field to aggregate on
*
* @extends TermsAggregationBase
*/
class TermsAggregation extends TermsAggregationBase {
// eslint-disable-next-line require-jsdoc
constructor(name, field) {
super(name, 'terms', ES_REF_URL, field);
}
/**
* When set to `true`, shows an error value for each term returned by the aggregation
* which represents the _worst case error_ in the document count and can be useful
* when deciding on a value for the shard_size parameter.
*
* @param {boolean} enable
* @returns {TermsAggregation} returns `this` so that calls can be chained
*/
showTermDocCountError(enable) {
this._aggsDef.show_term_doc_count_error = enable;
return this;
}
/**
* Break the analysis up into multiple requests by grouping the field’s values
* into a number of partitions at query-time and processing only one
* partition in each request.
*
* Note that this method is a special case as the name doesn't map to the
* elasticsearch parameter name. This is required because there is already
* a method for `include` applicable for Terms aggregations. However, this
* could change depending on community interest.
*
* @example
* const agg = esb.termsAggregation('expired_sessions', 'account_id')
* .includePartition(0, 20)
* .size(10000)
* .order('last_access', 'asc')
* .agg(esb.maxAggregation('last_access', 'access_date'));
*
* @param {number} partition
* @param {number} numPartitions
* @returns {TermsAggregation} returns `this` so that calls can be chained
*/
includePartition(partition, numPartitions) {
// TODO: Print warning if include key is being overwritten
this._aggsDef.include = {
partition,
num_partitions: numPartitions
};
return this;
}
/**
* Can be used for deferring calculation of child aggregations by using
* `breadth_first` mode. In `depth_first` mode all branches of the aggregation
* tree are expanded in one depth-first pass and only then any pruning occurs.
*
* @example
* const agg = esb.termsAggregation('actors', 'actors')
* .size(10)
* .collectMode('breadth_first')
* .agg(esb.termsAggregation('costars', 'actors').size(5));
*
* @param {string} mode The possible values are `breadth_first` and `depth_first`.
* @returns {TermsAggregation} returns `this` so that calls can be chained
*/
collectMode(mode) {
if (_.isNil(mode)) invalidCollectModeParam(mode);
const modeLower = mode.toLowerCase();
if (modeLower !== 'breadth_first' && modeLower !== 'depth_first') {
invalidCollectModeParam(mode);
}
this._aggsDef.collect_mode = modeLower;
return this;
}
/**
* Sets the ordering for buckets
*
* @example
* // Ordering the buckets by their doc `_count` in an ascending manner
* const agg = esb.termsAggregation('genres', 'genre').order('_count', 'asc');
*
* @example
* // Ordering the buckets alphabetically by their terms in an ascending manner
* const agg = esb.termsAggregation('genres', 'genre').order('_term', 'asc');
*
* @example
* // Ordering the buckets by single value metrics sub-aggregation
* // (identified by the aggregation name)
* const agg = esb.termsAggregation('genres', 'genre')
* .order('max_play_count', 'asc')
* .agg(esb.maxAggregation('max_play_count', 'play_count'));
*
* @example
* // Ordering the buckets by multi value metrics sub-aggregation
* // (identified by the aggregation name):
* const agg = esb.termsAggregation('genres', 'genre')
* .order('playback_stats.max', 'desc')
* .agg(esb.statsAggregation('playback_stats', 'play_count'));
*
* @example
* // Multiple order criteria
* const agg = esb.termsAggregation('countries')
* .field('artist.country')
* .order('rock>playback_stats.avg', 'desc')
* .order('_count', 'desc')
* .agg(
* esb.filterAggregation('rock')
* .filter(esb.termQuery('genre', 'rock'))
* .agg(esb.statsAggregation('playback_stats', 'play_count'))
* );
*
* @param {string} key
* @param {string} direction `asc` or `desc`
* @returns {TermsAggregation} returns `this` so that calls can be chained
*/
order(key, direction = 'desc') {
if (_.isNil(direction)) invalidDirectionParam(direction);
const directionLower = direction.toLowerCase();
if (directionLower !== 'asc' && directionLower !== 'desc') {
invalidDirectionParam(direction);
}
if (_.has(this._aggsDef, 'order')) {
if (!Array.isArray(this._aggsDef.order)) {
this._aggsDef.order = [this._aggsDef.order];
}
this._aggsDef.order.push({ [key]: directionLower });
} else {
this._aggsDef.order = { [key]: directionLower };
}
return this;
}
}
module.exports = TermsAggregation;
================================================
FILE: src/aggregations/bucket-aggregations/variable-width-histogram-aggregation.js
================================================
'use strict';
const _ = require('../../_');
const BucketAggregationBase = require('./bucket-aggregation-base');
/**
* This is a multi-bucket aggregation similar to Histogram.
* However, the width of each bucket is not specified.
* Rather, a target number of buckets is provided and bucket intervals are dynamically determined based on the document distribution.
* This is done using a simple one-pass document clustering algorithm that aims to obtain low distances between bucket centroids.
* Unlike other multi-bucket aggregations, the intervals will not necessarily have a uniform width.
*
* [Elasticsearch reference](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-variablewidthhistogram-aggregation.html)
*
* NOTE: Only available in Elasticsearch v7.9.0+
* @example
* const agg = esb.variableWidthHistogramAggregation('price', 'lowestPrice', 10)
*
* @param {string} name The name which will be used to refer to this aggregation.
* @param {string} [field] The field to aggregate on
* @param {number} [buckets] Bucket count to generate histogram over.
*
* @extends BucketAggregationBase
*/
class VariableWidthHistogramAggregation extends BucketAggregationBase {
// eslint-disable-next-line require-jsdoc
constructor(name, field, buckets) {
super(name, 'variable_width_histogram', field);
if (!_.isNil(buckets)) this._aggsDef.buckets = buckets;
}
/**
* Sets the histogram bucket count. Buckets are generated based on this value.
*
* @param {number} buckets Bucket count to generate histogram over.
* @returns {VariableWidthHistogramAggregation} returns `this` so that calls can be chained
*/
buckets(buckets) {
this._aggsDef.buckets = buckets;
return this;
}
}
module.exports = VariableWidthHistogramAggregation;
================================================
FILE: src/aggregations/index.js
================================================
'use strict';
// Not used in favor of explicit exports.
// IDE seems to handle those better
// const _ = require('lodash');
// const { util: { constructorWrapper } } = require('../core');
// const metricsAggs = require('./metrics-aggregations'),
// bucketAggs = require('./bucket-aggregations');
// /* === Metrics Aggregations === */
// for (const clsName in metricsAggs) {
// if (!has(metricsAggs, clsName)) continue;
// exports[clsName] = metricsAggs[clsName];
// exports[_.lowerFirst(clsName)] = constructorWrapper(metricsAggs[clsName]);
// }
// /* === Bucket Aggregations === */
// for (const clsName in bucketAggs) {
// if (!has(bucketAggs, clsName)) continue;
// exports[clsName] = bucketAggs[clsName];
// exports[_.lowerFirst(clsName)] = constructorWrapper(bucketAggs[clsName]);
// }
exports.metricsAggregations = require('./metrics-aggregations');
exports.bucketAggregations = require('./bucket-aggregations');
exports.pipelineAggregations = require('./pipeline-aggregations');
exports.matrixAggregations = require('./matrix-aggregations');
================================================
FILE: src/aggregations/matrix-aggregations/index.js
================================================
'use strict';
exports.MatrixStatsAggregation = require('./matrix-stats-aggregation');
================================================
FILE: src/aggregations/matrix-aggregations/matrix-stats-aggregation.js
================================================
'use strict';
const _ = require('../../_');
const {
Aggregation,
util: { checkType }
} = require('../../core');
/**
* The `matrix_stats` aggregation is a numeric aggregation that computes
* statistics over a set of document fields
*
* [Elasticsearch reference](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-matrix-stats-aggregation.html)
*
* @example
* const agg = esb.matrixStatsAggregation('matrixstats', ['poverty', 'income']);
*
* @param {string} name A valid aggregation name
* @param {Array=} fields Array of fields
*
* @extends Aggregation
*/
class MatrixStatsAggregation extends Aggregation {
// eslint-disable-next-line require-jsdoc
constructor(name, fields) {
super(name, 'matrix_stats');
if (!_.isNil(fields)) this.fields(fields);
}
/**
* The `fields` setting defines the set of fields (as an array) for computing
* the statistics.
*
* @example
* const agg = esb.matrixStatsAggregation('matrixstats')
* .fields(['poverty', 'income']);
*
* @param {Array<string>} fields Array of fields
* @returns {MatrixStatsAggregation} returns `this` so that calls can be chained
*/
fields(fields) {
checkType(fields, Array);
this._aggsDef.fields = fields;
return this;
}
/**
* The `mode` parameter controls what array value the aggregation will use for
* array or multi-valued fields
* @param {string} mode One of `avg`, `min`, `max`, `sum` and `median`
* @returns {MatrixStatsAggregation} returns `this` so that calls can be chained
*/
mode(mode) {
// TODO: Add a set in consts and validate input
this._aggsDef.mode = mode;
return this;
}
/**
* The missing parameter defines how documents that are missing a value should
* be treated. By default they will be ignored but it is also possible to treat
* them as if they had a value.
*
* @example
* const agg = esb.matrixStatsAggregation('matrixstats')
* .fields(['poverty', 'income'])
* .missing({ income: 50000 });
*
* @param {Object} missing Set of fieldname : value mappings to specify default
* values per field
* @returns {MatrixStatsAggregation} returns `this` so that calls can be chained
*/
missing(missing) {
this._aggsDef.missing = missing;
return this;
}
}
module.exports = MatrixStatsAggregation;
================================================
FILE: src/aggregations/metrics-aggregations/avg-aggregation.js
================================================
'use strict';
const MetricsAggregationBase = require('./metrics-aggregation-base');
/**
* A single-value metrics aggregation that computes the average of numeric
* values that are extracted from the aggregated documents. These values can be
* extracted either from specific numeric fields in the documents, or be
* generated by a provided script.
*
* [Elasticsearch reference](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-avg-aggregation.html)
*
* Aggregation that computes the average of numeric values that are extracted
* from the aggregated documents.
*
* @example
* // Compute the average grade over all documents
* const agg = esb.avgAggregation('avg_grade', 'grade');
*
* @example
* // Compute the average grade based on a script
* const agg = esb.avgAggregation('avg_grade').script(
* esb.script('inline', "doc['grade'].value").lang('painless')
* );
*
* @example
* // Value script, apply grade correction
* const agg = esb.avgAggregation('avg_grade', 'grade').script(
* esb.script('inline', '_value * params.correction')
* .lang('painless')
* .params({ correction: 1.2 })
* );
*
* @example
* // Missing value
* const agg = esb.avgAggregation('avg_grade', 'grade').missing(10);
*
* @param {string} name The name which will be used to refer to this aggregation.
* @param {string=} field The field to aggregate on
*
* @extends MetricsAggregationBase
*/
class AvgAggregation extends MetricsAggregationBase {
// eslint-disable-next-line require-jsdoc
constructor(name, field) {
super(name, 'avg', field);
}
}
module.exports = AvgAggregation;
================================================
FILE: src/aggregations/metrics-aggregations/cardinality-aggregation.js
================================================
'use strict';
const MetricsAggregationBase = require('./metrics-aggregation-base');
const ES_REF_URL =
'https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-cardinality-aggregation.html';
/**
* A single-value metrics aggregation that calculates an approximate count of
* distinct values. Values can be extracted either from specific fields in the
* document or generated by a script.
*
* [Elasticsearch reference](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-cardinality-aggregation.html)
*
* Aggregation that calculates an approximate count of distinct values.
*
* @example
* const agg = esb.cardinalityAggregation('author_count', 'author');
*
* @example
* const agg = esb.cardinalityAggregation('author_count').script(
* esb.script(
* 'inline',
* "doc['author.first_name'].value + ' ' + doc['author.last_name'].value"
* ).lang('painless')
* );
*
* @param {string} name The name which will be used to refer to this aggregation.
* @param {string=} field The field to aggregate on
*
* @extends MetricsAggregationBase
*/
class CardinalityAggregation extends MetricsAggregationBase {
// eslint-disable-next-line require-jsdoc
constructor(name, field) {
super(name, 'cardinality', field);
}
/**
* @override
* @throws {Error} This method cannot be called on CardinalityAggregation
*/
format() {
// Not 100% sure about this.
console.log(`Please refer ${ES_REF_URL}`);
throw new Error('format is not supported in CardinalityAggregation');
}
/**
* The `precision_threshold` options allows to trade memory for accuracy,
* and defines a unique count below which counts are expected to be close to accurate.
*
* @example
* const agg = esb.cardinalityAggregation(
* 'author_count',
* 'author_hash'
* ).precisionThreshold(100);
*
* @param {number} threshold The threshold value.
* The maximum supported value is 40000, thresholds above this number
* will have the same effect as a threshold of 40000. The default values is 3000.
* @returns {CardinalityAggregation} returns `this` so that calls can be chained
*/
precisionThreshold(threshold) {
// TODO: Use validation and warning here
this._aggsDef.precision_threshold = threshold;
return this;
}
}
module.exports = CardinalityAggregation;
================================================
FILE: src/aggregations/metrics-aggregations/extended-stats-aggregation.js
================================================
'use strict';
const MetricsAggregationBase = require('./metrics-aggregation-base');
/**
* A multi-value metrics aggregation that computes stats over numeric values
* extracted from the aggregated documents. These values can be extracted either
* from specific numeric fields in the documents, or be generated by a provided
* script.
*
* [Elasticsearch reference](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-extendedstats-aggregation.html)
*
* Aggregation that computes extra stats over numeric values extracted from
* the aggregated documents.
*
* @example
* const agg = esb.extendedStatsAggregation('grades_stats', 'grade');
*
* @example
* // Compute the grade stats based on a script
* const agg = esb.extendedStatsAggregation('grades_stats').script(
* esb.script('inline', "doc['grade'].value").lang('painless')
* );
*
* @example
* // Value script, apply grade correction
* const agg = esb.extendedStatsAggregation('grades_stats', 'grade').script(
* esb.script('inline', '_value * params.correction')
* .lang('painless')
* .params({ correction: 1.2 })
* );
*
* @example
* // Missing value
* const agg = esb.extendedStatsAggregation('grades_stats', 'grade').missing(0);
*
* @param {string} name The name which will be used to refer to this aggregation.
* @param {string=} field The field to aggregate on
*
* @extends MetricsAggregationBase
*/
class ExtendedStatsAggregation extends MetricsAggregationBase {
// eslint-disable-next-line require-jsdoc
constructor(name, field) {
super(name, 'extended_stats', field);
}
/**
* Set sigma in the request for getting custom boundary.
* sigma controls how many standard deviations +/- from the mean should be displayed
*
* @example
* const agg = esb.extendedStatsAggregation('grades_stats', 'grade').sigma(3);
*
* @param {number} sigma sigma can be any non-negative double,
* meaning you can request non-integer values such as 1.5.
* A value of 0 is valid, but will simply return the average for both upper and lower bounds.
* @returns {ExtendedStatsAggregation} returns `this` so that calls can be chained
*/
sigma(sigma) {
this._aggsDef.sigma = sigma;
return this;
}
}
module.exports = ExtendedStatsAggregation;
================================================
FILE: src/aggregations/metrics-aggregations/geo-bounds-aggregation.js
================================================
'use strict';
const MetricsAggregationBase = require('./metrics-aggregation-base');
const ES_REF_URL =
'https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-geobounds-aggregation.html';
/**
* A metric aggregation that computes the bounding box
* containing all geo_point values for a field.
*
* [Elasticsearch reference](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-geobounds-aggregation.html)
*
* @example
* const agg = esb.geoBoundsAggregation('viewport', 'location').wrapLongitude(true);
*
* @param {string} name The name which will be used to refer to this aggregation.
* @param {string=} field The field to aggregate on
*
* @extends MetricsAggregationBase
*/
class GeoBoundsAggregation extends MetricsAggregationBase {
// eslint-disable-next-line require-jsdoc
constructor(name, field) {
super(name, 'geo_bounds', field);
}
// TODO: Override missing and take only GeoPoint as parameter
/**
* @override
* @throws {Error} This method cannot be called on GeoBoundsAggregation
*/
format() {
console.log(`Please refer ${ES_REF_URL}`);
throw new Error('format is not supported in GeoBoundsAggregation');
}
/**
* @override
* @throws {Error} This method cannot be called on GeoBoundsAggregation
*/
script() {
console.log(`Please refer ${ES_REF_URL}`);
throw new Error('script is not supported in GeoBoundsAggregation');
}
/**
*
* @param {boolean} allowOverlap Optional parameter which specifies whether
* the bounding box should be allowed to overlap the international date line.
* The default value is true
* @returns {GeoBoundsAggregation} returns `this` so that calls can be chained
*/
wrapLongitude(allowOverlap) {
this._aggsDef.wrap_longitude = allowOverlap;
return this;
}
}
module.exports = GeoBoundsAggregation;
================================================
FILE: src/aggregations/metrics-aggregations/geo-centroid-aggregation.js
================================================
'use strict';
const MetricsAggregationBase = require('./metrics-aggregation-base');
const ES_REF_URL =
'https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-geocentroid-aggregation.html';
/**
* A metric aggregation that computes the weighted centroid
* from all coordinate values for a Geo-point datatype field.
*
* [Elasticsearchreference](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-geocentroid-aggregation.html)
*
* @example
* const agg = esb.geoCentroidAggregation('centroid', 'location');
*
* @example
* // Combined as a sub-aggregation to other bucket aggregations
* const reqBody = esb.requestBodySearch()
* .query(esb.matchQuery('crime', 'burglary'))
* .agg(
* esb.termsAggregation('towns', 'town').agg(
* esb.geoCentroidAggregation('centroid', 'location')
* )
* );
*
* @param {string} name The name which will be used to refer to this aggregation.
* @param {string=} field The field to aggregate on. field must be a Geo-point datatype type
*
* @extends MetricsAggregationBase
*/
class GeoCentroidAggregation extends MetricsAggregationBase {
// eslint-disable-next-line require-jsdoc
constructor(name, field) {
super(name, 'geo_centroid', field);
}
/**
* @override
* @throws {Error} This method cannot be called on GeoCentroidAggregation
*/
format() {
console.log(`Please refer ${ES_REF_URL}`);
throw new Error('format is not supported in GeoCentroidAggregation');
}
}
module.exports = GeoCentroidAggregation;
================================================
FILE: src/aggregations/metrics-aggregations/index.js
================================================
'use strict';
exports.MetricsAggregationBase = require('./metrics-aggregation-base');
exports.AvgAggregation = require('./avg-aggregation');
exports.CardinalityAggregation = require('./cardinality-aggregation');
exports.ExtendedStatsAggregation = require('./extended-stats-aggregation');
exports.GeoBoundsAggregation = require('./geo-bounds-aggregation');
exports.GeoCentroidAggregation = require('./geo-centroid-aggregation');
exports.MaxAggregation = require('./max-aggregation');
exports.MinAggregation = require('./min-aggregation');
exports.PercentilesAggregation = require('./percentiles-aggregation');
exports.PercentileRanksAggregation = require('./percentile-ranks-aggregation');
exports.ScriptedMetricAggregation = require('./scripted-metric-aggregation');
exports.StatsAggregation = require('./stats-aggregation');
exports.SumAggregation = require('./sum-aggregation');
exports.TopHitsAggregation = require('./top-hits-aggregation');
exports.ValueCountAggregation = require('./value-count-aggregation');
exports.WeightedAverageAggregation = require('./weighted-average-aggregation');
================================================
FILE: src/aggregations/metrics-aggregations/max-aggregation.js
================================================
'use strict';
const MetricsAggregationBase = require('./metrics-aggregation-base');
/**
* A single-value metrics aggregation that keeps track and returns the
* maximum value amo
gitextract_owzxfn2s/ ├── .eslintignore ├── .eslintrc.yml ├── .gitattributes ├── .github/ │ └── workflows/ │ └── build.yml ├── .gitignore ├── .nvmrc ├── .prettierrc.json ├── .releaserc.json ├── .vscode/ │ ├── extensions.json │ └── settings.json ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── deploy-docs.sh ├── docs/ │ ├── documentation.yml │ ├── intro.md │ └── publish.md ├── jsconfig.json ├── package.json ├── repl.js ├── roadmap.md ├── src/ │ ├── README.md │ ├── _/ │ │ └── index.js │ ├── aggregations/ │ │ ├── bucket-aggregations/ │ │ │ ├── adjacency-matrix-aggregation.js │ │ │ ├── auto-date-histogram-aggregation.js │ │ │ ├── bucket-aggregation-base.js │ │ │ ├── children-aggregation.js │ │ │ ├── composite-agg-values-sources/ │ │ │ │ ├── date-histogram-values-source.js │ │ │ │ ├── histogram-values-source.js │ │ │ │ ├── index.js │ │ │ │ ├── terms-values-source.js │ │ │ │ └── values-source-base.js │ │ │ ├── composite-aggregation.js │ │ │ ├── date-histogram-aggregation.js │ │ │ ├── date-range-aggregation.js │ │ │ ├── diversified-sampler-aggregation.js │ │ │ ├── filter-aggregation.js │ │ │ ├── filters-aggregation.js │ │ │ ├── geo-distance-aggregation.js │ │ │ ├── geo-hash-grid-aggregation.js │ │ │ ├── geo-hex-grid-aggregation.js │ │ │ ├── geo-tile-grid-aggregation.js │ │ │ ├── global-aggregation.js │ │ │ ├── histogram-aggregation-base.js │ │ │ ├── histogram-aggregation.js │ │ │ ├── index.js │ │ │ ├── ip-range-aggregation.js │ │ │ ├── missing-aggregation.js │ │ │ ├── nested-aggregation.js │ │ │ ├── parent-aggregation.js │ │ │ ├── range-aggregation-base.js │ │ │ ├── range-aggregation.js │ │ │ ├── rare-terms-aggregation.js │ │ │ ├── reverse-nested-aggregation.js │ │ │ ├── sampler-aggregation.js │ │ │ ├── significant-aggregation-base.js │ │ │ ├── significant-terms-aggregation.js │ │ │ ├── significant-text-aggregation.js │ │ │ ├── terms-aggregation-base.js │ │ │ ├── terms-aggregation.js │ │ │ └── variable-width-histogram-aggregation.js │ │ ├── index.js │ │ ├── matrix-aggregations/ │ │ │ ├── index.js │ │ │ └── matrix-stats-aggregation.js │ │ ├── metrics-aggregations/ │ │ │ ├── avg-aggregation.js │ │ │ ├── cardinality-aggregation.js │ │ │ ├── extended-stats-aggregation.js │ │ │ ├── geo-bounds-aggregation.js │ │ │ ├── geo-centroid-aggregation.js │ │ │ ├── index.js │ │ │ ├── max-aggregation.js │ │ │ ├── metrics-aggregation-base.js │ │ │ ├── min-aggregation.js │ │ │ ├── percentile-ranks-aggregation.js │ │ │ ├── percentiles-aggregation.js │ │ │ ├── scripted-metric-aggregation.js │ │ │ ├── stats-aggregation.js │ │ │ ├── sum-aggregation.js │ │ │ ├── top-hits-aggregation.js │ │ │ ├── value-count-aggregation.js │ │ │ └── weighted-average-aggregation.js │ │ └── pipeline-aggregations/ │ │ ├── avg-bucket-aggregation.js │ │ ├── bucket-script-aggregation.js │ │ ├── bucket-selector-aggregation.js │ │ ├── bucket-sort-aggregation.js │ │ ├── cumulative-sum-aggregation.js │ │ ├── derivative-aggregation.js │ │ ├── extended-stats-bucket-aggregation.js │ │ ├── index.js │ │ ├── max-bucket-aggregation.js │ │ ├── min-bucket-aggregation.js │ │ ├── moving-average-aggregation.js │ │ ├── moving-function-aggregation.js │ │ ├── percentiles-bucket-aggregation.js │ │ ├── pipeline-aggregation-base.js │ │ ├── serial-differencing-aggregation.js │ │ ├── stats-bucket-aggregation.js │ │ └── sum-bucket-aggregation.js │ ├── core/ │ │ ├── aggregation.js │ │ ├── consts.js │ │ ├── geo-point.js │ │ ├── geo-shape.js │ │ ├── highlight.js │ │ ├── index.js │ │ ├── indexed-shape.js │ │ ├── inner-hits.js │ │ ├── inspect.js │ │ ├── knn.js │ │ ├── query.js │ │ ├── request-body-search.js │ │ ├── rescore.js │ │ ├── runtime-field.js │ │ ├── script.js │ │ ├── search-template.js │ │ ├── sort.js │ │ ├── suggester.js │ │ └── util.js │ ├── index.d.ts │ ├── index.js │ ├── queries/ │ │ ├── compound-queries/ │ │ │ ├── bool-query.js │ │ │ ├── boosting-query.js │ │ │ ├── constant-score-query.js │ │ │ ├── dis-max-query.js │ │ │ ├── function-score-query.js │ │ │ ├── index.js │ │ │ └── score-functions/ │ │ │ ├── decay-score-function.js │ │ │ ├── field-value-factor-function.js │ │ │ ├── index.js │ │ │ ├── random-score-function.js │ │ │ ├── score-function.js │ │ │ ├── script-score-function.js │ │ │ └── weight-score-function.js │ │ ├── full-text-queries/ │ │ │ ├── combined-fields-query.js │ │ │ ├── common-terms-query.js │ │ │ ├── full-text-query-base.js │ │ │ ├── index.js │ │ │ ├── match-phrase-prefix-query.js │ │ │ ├── match-phrase-query-base.js │ │ │ ├── match-phrase-query.js │ │ │ ├── match-query.js │ │ │ ├── mono-field-query-base.js │ │ │ ├── multi-match-query.js │ │ │ ├── query-string-query-base.js │ │ │ ├── query-string-query.js │ │ │ └── simple-query-string-query.js │ │ ├── geo-queries/ │ │ │ ├── geo-bounding-box-query.js │ │ │ ├── geo-distance-query.js │ │ │ ├── geo-polygon-query.js │ │ │ ├── geo-query-base.js │ │ │ ├── geo-shape-query.js │ │ │ └── index.js │ │ ├── helper.js │ │ ├── index.js │ │ ├── joining-queries/ │ │ │ ├── has-child-query.js │ │ │ ├── has-parent-query.js │ │ │ ├── index.js │ │ │ ├── joining-query-base.js │ │ │ ├── nested-query.js │ │ │ └── parent-id-query.js │ │ ├── match-all-query.js │ │ ├── match-none-query.js │ │ ├── span-queries/ │ │ │ ├── index.js │ │ │ ├── span-containing-query.js │ │ │ ├── span-field-masking-query.js │ │ │ ├── span-first-query.js │ │ │ ├── span-little-big-query-base.js │ │ │ ├── span-multi-term-query.js │ │ │ ├── span-near-query.js │ │ │ ├── span-not-query.js │ │ │ ├── span-or-query.js │ │ │ ├── span-query-base.js │ │ │ ├── span-term-query.js │ │ │ └── span-within-query.js │ │ ├── specialized-queries/ │ │ │ ├── distance-feature-query.js │ │ │ ├── index.js │ │ │ ├── more-like-this-query.js │ │ │ ├── percolate-query.js │ │ │ ├── rank-feature-query.js │ │ │ ├── script-query.js │ │ │ └── script-score-query.js │ │ ├── term-level-queries/ │ │ │ ├── exists-query.js │ │ │ ├── fuzzy-query.js │ │ │ ├── ids-query.js │ │ │ ├── index.js │ │ │ ├── multi-term-query-base.js │ │ │ ├── prefix-query.js │ │ │ ├── range-query.js │ │ │ ├── regexp-query.js │ │ │ ├── term-query.js │ │ │ ├── terms-query.js │ │ │ ├── terms-set-query.js │ │ │ ├── type-query.js │ │ │ ├── value-term-query-base.js │ │ │ └── wildcard-query.js │ │ └── vector-queries/ │ │ ├── index.js │ │ ├── semantic-query.js │ │ └── sparse-vector-query.js │ ├── recipes.js │ └── suggesters/ │ ├── analyzed-suggester-base.js │ ├── completion-suggester.js │ ├── direct-generator.js │ ├── index.js │ ├── phrase-suggester.js │ └── term-suggester.js ├── test/ │ ├── .eslintrc.yml │ ├── _/ │ │ └── index.test.js │ ├── aggregations-test/ │ │ ├── adjacency-matrix-agg.test.js │ │ ├── auto-date-histogram-agg.test.js │ │ ├── avg-agg.test.js │ │ ├── avg-bucket-agg.test.js │ │ ├── bucket-agg-base.test.js │ │ ├── bucket-script-agg.test.js │ │ ├── bucket-selector-agg.test.js │ │ ├── bucket-sort-agg.test.js │ │ ├── cardinality-agg.test.js │ │ ├── children-agg.test.js │ │ ├── composite-agg-values-sources-test/ │ │ │ ├── date-histogram-values-source.test.js │ │ │ ├── histogram-values-source.test.js │ │ │ └── terms-values-source.test.js │ │ ├── composite-agg.test.js │ │ ├── cumulative-sum-agg.test.js │ │ ├── date-histogram-agg.test.js │ │ ├── date-range-agg.test.js │ │ ├── derivative-agg.test.js │ │ ├── diversified-sampler-agg.test.js │ │ ├── extended-stats-agg.test.js │ │ ├── extended-stats-bucket-agg.test.js │ │ ├── filter-agg.test.js │ │ ├── filters-agg.test.js │ │ ├── geo-bounds-agg.test.js │ │ ├── geo-centroid-agg.test.js │ │ ├── geo-distance-agg.test.js │ │ ├── geo-hash-grid-agg.test.js │ │ ├── geo-hex-grid-agg.test.js │ │ ├── geo-tile-grid-agg.test.js │ │ ├── global-agg.test.js │ │ ├── histogram-agg-base.test.js │ │ ├── histogram-agg.test.js │ │ ├── ip-range-agg.test.js │ │ ├── matrix-stats-agg.test.js │ │ ├── max-agg.test.js │ │ ├── max-bucket-agg.test.js │ │ ├── metrics-agg-base.test.js │ │ ├── min-agg.test.js │ │ ├── min-bucket-agg.test.js │ │ ├── missing-agg.test.js │ │ ├── moving-average-agg.test.js │ │ ├── moving-function-agg.test.js │ │ ├── nested-agg.test.js │ │ ├── parent-agg.test.js │ │ ├── percentile-ranks-agg.test.js │ │ ├── percentiles-agg.test.js │ │ ├── percentiles-bucket-agg.test.js │ │ ├── pipeline-agg-base.test.js │ │ ├── range-agg-base.test.js │ │ ├── range-agg.test.js │ │ ├── rare-terms-aggregation.test.js │ │ ├── reverse-nested-agg.test.js │ │ ├── sampler-agg.test.js │ │ ├── scripted-metric-agg.test.js │ │ ├── serial-differencing-agg.test.js │ │ ├── significant-agg-base.test.js │ │ ├── significant-terms-agg.test.js │ │ ├── significant-text-agg.test.js │ │ ├── stats-agg.test.js │ │ ├── stats-bucket-agg.test.js │ │ ├── sum-agg.test.js │ │ ├── sum-bucket-agg.test.js │ │ ├── terms-agg-base.test.js │ │ ├── terms-agg.test.js │ │ ├── top-hits-agg.test.js │ │ ├── value-count-agg.test.js │ │ ├── variable-width-histogram-aggregation.test.js │ │ └── weighted-average-aggregation.test.js │ ├── core-test/ │ │ ├── aggregation.test.js │ │ ├── geo-point.test.js │ │ ├── geo-shape.test.js │ │ ├── highlight.test.js │ │ ├── indexed-shape.test.js │ │ ├── inner-hits.test.js │ │ ├── knn.test.js │ │ ├── query.test.js │ │ ├── request-body-search.test.js │ │ ├── rescore.test.js │ │ ├── runtime-field.test.js │ │ ├── script.test.js │ │ ├── search-template.test.js │ │ ├── sort.test.js │ │ ├── suggester.test.js │ │ └── util.test.js │ ├── index.test.js │ ├── queries-test/ │ │ ├── bool-query.test.js │ │ ├── boosting-query.test.js │ │ ├── combined-fields-query.test.js │ │ ├── common-terms-query.test.js │ │ ├── constant-score-query.test.js │ │ ├── decay-score-func.test.js │ │ ├── dis-max-query.test.js │ │ ├── distance-feature.test.js │ │ ├── exists-query.test.js │ │ ├── field-value-factor-func.test.js │ │ ├── full-text-query-base.test.js │ │ ├── function-score-query.test.js │ │ ├── fuzzy-query.test.js │ │ ├── geo-bounding-box-query.test.js │ │ ├── geo-distance-query.test.js │ │ ├── geo-polygon-query.test.js │ │ ├── geo-query-base.test.js │ │ ├── geo-shape-query.test.js │ │ ├── has-child-query.test.js │ │ ├── has-parent-query.test.js │ │ ├── ids-query.test.js │ │ ├── joining-query-base.test.js │ │ ├── match-all-query.test.js │ │ ├── match-none-query.test.js │ │ ├── match-phrase-prefix-query.test.js │ │ ├── match-phrase-query-base.test.js │ │ ├── match-phrase-query.test.js │ │ ├── match-query.test.js │ │ ├── mono-field-query-base.test.js │ │ ├── more-like-this-query.test.js │ │ ├── multi-match-query.test.js │ │ ├── nested-query.test.js │ │ ├── parent-id-query.test.js │ │ ├── percolate-query.test.js │ │ ├── prefix-query.test.js │ │ ├── query-string-query-base.test.js │ │ ├── query-string-query.test.js │ │ ├── random-score-func.test.js │ │ ├── range-query.test.js │ │ ├── rank-feature.test.js │ │ ├── regexp-query.test.js │ │ ├── score-func.test.js │ │ ├── script-query.test.js │ │ ├── script-score-func.test.js │ │ ├── script-score-query.test.js │ │ ├── semantic-query.test.js │ │ ├── simple-query-string-query.test.js │ │ ├── span-containing-query.test.js │ │ ├── span-field-masking-query.test.js │ │ ├── span-first-query.test.js │ │ ├── span-little-big-query-base.test.js │ │ ├── span-multi-term-query.test.js │ │ ├── span-near-query.test.js │ │ ├── span-not-query.test.js │ │ ├── span-or-query.test.js │ │ ├── span-term-query.test.js │ │ ├── span-within-query.test.js │ │ ├── sparse-vector-query.test.js │ │ ├── term-query.test.js │ │ ├── terms-query.test.js │ │ ├── terms-set-query.test.js │ │ ├── type-query.test.js │ │ ├── weight-score-func.test.js │ │ └── wildcard-query.test.js │ ├── recipes.test.js │ ├── suggesters-test/ │ │ ├── analyzed-suggester-base.test.js │ │ ├── completion-suggester.test.js │ │ ├── direct-generator.test.js │ │ ├── phrase-suggester.test.js │ │ └── term-suggester.test.js │ ├── testing-guidelines.mdc │ ├── testutil/ │ │ └── index.js │ └── typedef.test.ts ├── vitest.config.js └── webpack.config.js
SYMBOL INDEX (1272 symbols across 162 files)
FILE: src/aggregations/bucket-aggregations/adjacency-matrix-aggregation.js
constant ES_REF_URL (line 10) | const ES_REF_URL =
class AdjacencyMatrixAggregation (line 32) | class AdjacencyMatrixAggregation extends BucketAggregationBase {
method constructor (line 34) | constructor(name) {
method field (line 42) | field() {
method script (line 51) | script() {
method filter (line 66) | filter(filterName, filterQuery) {
method filters (line 85) | filters(filterQueries) {
method separator (line 103) | separator(sep) {
FILE: src/aggregations/bucket-aggregations/auto-date-histogram-aggregation.js
class AutoDateHistogramAggregation (line 25) | class AutoDateHistogramAggregation extends BucketAggregationBase {
method constructor (line 27) | constructor(name, field, buckets) {
method buckets (line 38) | buckets(buckets) {
method minimumInterval (line 62) | minimumInterval(interval) {
method format (line 82) | format(fmt) {
method missing (line 97) | missing(value) {
method timeZone (line 118) | timeZone(tz) {
FILE: src/aggregations/bucket-aggregations/bucket-aggregation-base.js
class BucketAggregationBase (line 25) | class BucketAggregationBase extends Aggregation {
method constructor (line 27) | constructor(name, aggType, field) {
method field (line 39) | field(field) {
method script (line 63) | script(script) {
FILE: src/aggregations/bucket-aggregations/children-aggregation.js
constant ES_REF_URL (line 5) | const ES_REF_URL =
class ChildrenAggregation (line 38) | class ChildrenAggregation extends BucketAggregationBase {
method constructor (line 40) | constructor(name) {
method field (line 48) | field() {
method script (line 57) | script() {
method type (line 68) | type(type) {
FILE: src/aggregations/bucket-aggregations/composite-agg-values-sources/date-histogram-values-source.js
constant REF_URL (line 7) | const REF_URL =
class DateHistogramValuesSource (line 30) | class DateHistogramValuesSource extends ValuesSourceBase {
method constructor (line 32) | constructor(name, field, interval) {
method interval (line 44) | interval(interval) {
method calendarInterval (line 64) | calendarInterval(interval) {
method fixedInterval (line 87) | fixedInterval(interval) {
method timeZone (line 104) | timeZone(tz) {
method format (line 123) | format(fmt) {
FILE: src/aggregations/bucket-aggregations/composite-agg-values-sources/histogram-values-source.js
constant REF_URL (line 7) | const REF_URL =
class HistogramValuesSource (line 30) | class HistogramValuesSource extends ValuesSourceBase {
method constructor (line 32) | constructor(name, field, interval) {
method interval (line 44) | interval(interval) {
FILE: src/aggregations/bucket-aggregations/composite-agg-values-sources/terms-values-source.js
constant REF_URL (line 5) | const REF_URL =
class TermsValuesSource (line 26) | class TermsValuesSource extends ValuesSourceBase {
method constructor (line 28) | constructor(name, field) {
FILE: src/aggregations/bucket-aggregations/composite-agg-values-sources/values-source-base.js
class ValuesSourceBase (line 24) | class ValuesSourceBase {
method constructor (line 26) | constructor(valueSrcType, refUrl, name, field) {
method field (line 46) | field(field) {
method script (line 58) | script(script) {
method valueType (line 70) | valueType(valueType) {
method order (line 83) | order(order) {
method missing (line 106) | missing(value) {
method missingBucket (line 121) | missingBucket(value) {
method toJSON (line 133) | toJSON() {
FILE: src/aggregations/bucket-aggregations/composite-aggregation.js
class CompositeAggregation (line 41) | class CompositeAggregation extends Aggregation {
method constructor (line 43) | constructor(name) {
method sources (line 73) | sources(...sources) {
method size (line 90) | size(size) {
method after (line 118) | after(afterKey) {
FILE: src/aggregations/bucket-aggregations/date-histogram-aggregation.js
class DateHistogramAggregation (line 28) | class DateHistogramAggregation extends HistogramAggregationBase {
method constructor (line 30) | constructor(name, field, interval) {
method timeZone (line 50) | timeZone(tz) {
method calendarInterval (line 70) | calendarInterval(interval) {
method fixedInterval (line 94) | fixedInterval(interval) {
FILE: src/aggregations/bucket-aggregations/date-range-aggregation.js
class DateRangeAggregation (line 24) | class DateRangeAggregation extends RangeAggregationBase {
method constructor (line 26) | constructor(name, field) {
method timeZone (line 51) | timeZone(tz) {
FILE: src/aggregations/bucket-aggregations/diversified-sampler-aggregation.js
constant ES_REF_URL (line 12) | const ES_REF_URL =
class DiversifiedSamplerAggregation (line 66) | class DiversifiedSamplerAggregation extends BucketAggregationBase {
method constructor (line 68) | constructor(name, field) {
method shardSize (line 79) | shardSize(size) {
method maxDocsPerValue (line 92) | maxDocsPerValue(maxDocsPerValue) {
method executionHint (line 108) | executionHint(hint) {
FILE: src/aggregations/bucket-aggregations/filter-aggregation.js
constant ES_REF_URL (line 12) | const ES_REF_URL =
class FilterAggregation (line 37) | class FilterAggregation extends BucketAggregationBase {
method constructor (line 39) | constructor(name, filterQuery) {
method field (line 49) | field() {
method script (line 58) | script() {
method filter (line 75) | filter(filterQuery) {
FILE: src/aggregations/bucket-aggregations/filters-aggregation.js
constant ES_REF_URL (line 12) | const ES_REF_URL =
class FiltersAggregation (line 39) | class FiltersAggregation extends BucketAggregationBase {
method constructor (line 41) | constructor(name) {
method field (line 49) | field() {
method script (line 58) | script() {
method _warn (line 69) | _warn(msg) {
method _checkNamedFilters (line 80) | _checkNamedFilters() {
method _checkAnonymousFilters (line 98) | _checkAnonymousFilters() {
method filter (line 120) | filter(bucketName, filterQuery) {
method filters (line 139) | filters(filterQueries) {
method anonymousFilter (line 157) | anonymousFilter(filterQuery) {
method anonymousFilters (line 176) | anonymousFilters(filterQueries) {
method otherBucket (line 198) | otherBucket(enable, otherBucketKey) {
method otherBucketKey (line 220) | otherBucketKey(otherBucketKey) {
FILE: src/aggregations/bucket-aggregations/geo-distance-aggregation.js
constant ES_REF_URL (line 13) | const ES_REF_URL =
class GeoDistanceAggregation (line 44) | class GeoDistanceAggregation extends RangeAggregationBase {
method constructor (line 46) | constructor(name, field) {
method format (line 54) | format() {
method script (line 63) | script() {
method origin (line 75) | origin(point) {
method unit (line 98) | unit(unit) {
method distanceType (line 123) | distanceType(type) {
FILE: src/aggregations/bucket-aggregations/geo-hash-grid-aggregation.js
constant ES_REF_URL (line 7) | const ES_REF_URL =
class GeoHashGridAggregation (line 26) | class GeoHashGridAggregation extends BucketAggregationBase {
method constructor (line 28) | constructor(name, field) {
method format (line 36) | format() {
method script (line 45) | script() {
method precision (line 57) | precision(precision) {
method size (line 75) | size(size) {
method shardSize (line 87) | shardSize(shardSize) {
FILE: src/aggregations/bucket-aggregations/geo-hex-grid-aggregation.js
constant ES_REF_URL (line 7) | const ES_REF_URL =
class GeoHexGridAggregation (line 28) | class GeoHexGridAggregation extends BucketAggregationBase {
method constructor (line 30) | constructor(name, field) {
method format (line 38) | format() {
method script (line 47) | script() {
method precision (line 59) | precision(precision) {
method size (line 77) | size(size) {
method shardSize (line 89) | shardSize(shardSize) {
FILE: src/aggregations/bucket-aggregations/geo-tile-grid-aggregation.js
constant ES_REF_URL (line 12) | const ES_REF_URL =
class GeoTileGridAggregation (line 34) | class GeoTileGridAggregation extends BucketAggregationBase {
method constructor (line 36) | constructor(name, field) {
method format (line 44) | format() {
method script (line 53) | script() {
method precision (line 66) | precision(precision) {
method size (line 84) | size(size) {
method shardSize (line 100) | shardSize(shardSize) {
method topLeft (line 112) | topLeft(point) {
method bottomRight (line 126) | bottomRight(point) {
method topRight (line 140) | topRight(point) {
method bottomLeft (line 154) | bottomLeft(point) {
method top (line 167) | top(val) {
method left (line 179) | left(val) {
method bottom (line 191) | bottom(val) {
method right (line 203) | right(val) {
FILE: src/aggregations/bucket-aggregations/global-aggregation.js
constant ES_REF_URL (line 5) | const ES_REF_URL =
class GlobalAggregation (line 29) | class GlobalAggregation extends BucketAggregationBase {
method constructor (line 31) | constructor(name) {
method field (line 39) | field() {
method script (line 48) | script() {
FILE: src/aggregations/bucket-aggregations/histogram-aggregation-base.js
class HistogramAggregationBase (line 29) | class HistogramAggregationBase extends BucketAggregationBase {
method constructor (line 31) | constructor(name, aggType, field, interval) {
method interval (line 45) | interval(interval) {
method format (line 65) | format(fmt) {
method offset (line 83) | offset(offset) {
method order (line 108) | order(key, direction = 'desc') {
method minDocCount (line 139) | minDocCount(minDocCnt) {
method extendedBounds (line 164) | extendedBounds(min, max) {
method hardBounds (line 190) | hardBounds(min, max) {
method missing (line 205) | missing(value) {
method keyed (line 222) | keyed(keyed) {
FILE: src/aggregations/bucket-aggregations/histogram-aggregation.js
class HistogramAggregation (line 31) | class HistogramAggregation extends HistogramAggregationBase {
method constructor (line 33) | constructor(name, field, interval) {
FILE: src/aggregations/bucket-aggregations/ip-range-aggregation.js
constant ES_REF_URL (line 5) | const ES_REF_URL =
class IpRangeAggregation (line 30) | class IpRangeAggregation extends RangeAggregationBase {
method constructor (line 32) | constructor(name, field) {
method format (line 42) | format() {
FILE: src/aggregations/bucket-aggregations/missing-aggregation.js
constant ES_REF_URL (line 5) | const ES_REF_URL =
class MissingAggregation (line 23) | class MissingAggregation extends BucketAggregationBase {
method constructor (line 25) | constructor(name, field) {
method script (line 33) | script() {
FILE: src/aggregations/bucket-aggregations/nested-aggregation.js
constant ES_REF_URL (line 7) | const ES_REF_URL =
class NestedAggregation (line 30) | class NestedAggregation extends BucketAggregationBase {
method constructor (line 32) | constructor(name, path) {
method field (line 42) | field() {
method script (line 51) | script() {
method path (line 62) | path(path) {
FILE: src/aggregations/bucket-aggregations/parent-aggregation.js
constant ES_REF_URL (line 7) | const ES_REF_URL =
class ParentAggregation (line 41) | class ParentAggregation extends BucketAggregationBase {
method constructor (line 43) | constructor(name, type) {
method field (line 53) | field() {
method script (line 62) | script() {
method type (line 73) | type(type) {
FILE: src/aggregations/bucket-aggregations/range-aggregation-base.js
class RangeAggregationBase (line 28) | class RangeAggregationBase extends BucketAggregationBase {
method constructor (line 30) | constructor(name, aggType, field) {
method format (line 45) | format(fmt) {
method range (line 60) | range(range) {
method ranges (line 84) | ranges(ranges) {
method missing (line 98) | missing(value) {
method keyed (line 126) | keyed(keyed) {
method toJSON (line 137) | toJSON() {
FILE: src/aggregations/bucket-aggregations/range-aggregation.js
class RangeAggregation (line 50) | class RangeAggregation extends RangeAggregationBase {
method constructor (line 52) | constructor(name, field) {
FILE: src/aggregations/bucket-aggregations/rare-terms-aggregation.js
constant ES_REF_URL (line 7) | const ES_REF_URL =
class RareTermsAggregation (line 31) | class RareTermsAggregation extends BucketAggregationBase {
method constructor (line 33) | constructor(name, field) {
method maxDocCount (line 47) | maxDocCount(maxDocCnt) {
method precision (line 67) | precision(precision) {
method include (line 86) | include(include) {
method exclude (line 101) | exclude(exclude) {
method missing (line 113) | missing(value) {
method script (line 122) | script() {
FILE: src/aggregations/bucket-aggregations/reverse-nested-aggregation.js
constant ES_REF_URL (line 7) | const ES_REF_URL =
class ReverseNestedAggregation (line 42) | class ReverseNestedAggregation extends BucketAggregationBase {
method constructor (line 44) | constructor(name, path) {
method field (line 54) | field() {
method script (line 63) | script() {
method path (line 77) | path(path) {
FILE: src/aggregations/bucket-aggregations/sampler-aggregation.js
constant ES_REF_URL (line 5) | const ES_REF_URL =
class SamplerAggregation (line 33) | class SamplerAggregation extends BucketAggregationBase {
method constructor (line 35) | constructor(name) {
method field (line 43) | field() {
method script (line 52) | script() {
method shardSize (line 64) | shardSize(size) {
FILE: src/aggregations/bucket-aggregations/significant-aggregation-base.js
class SignificantAggregationBase (line 21) | class SignificantAggregationBase extends TermsAggregationBase {
method jlh (line 27) | jlh() {
method mutualInformation (line 45) | mutualInformation(includeNegatives = true, backgroundIsSuperset = true) {
method chiSquare (line 64) | chiSquare(includeNegatives = true, backgroundIsSuperset = true) {
method gnd (line 80) | gnd(backgroundIsSuperset = true) {
method percentage (line 94) | percentage() {
method scriptHeuristic (line 105) | scriptHeuristic(script) {
method backgroundFilter (line 128) | backgroundFilter(filterQuery) {
method script (line 139) | script() {
FILE: src/aggregations/bucket-aggregations/significant-terms-aggregation.js
constant ES_REF_URL (line 5) | const ES_REF_URL =
class SignificantTermsAggregation (line 35) | class SignificantTermsAggregation extends SignificantAggregationBase {
method constructor (line 37) | constructor(name, field) {
FILE: src/aggregations/bucket-aggregations/significant-text-aggregation.js
constant ES_REF_URL (line 9) | const ES_REF_URL =
class SignificantTextAggregation (line 39) | class SignificantTextAggregation extends SignificantAggregationBase {
method constructor (line 41) | constructor(name, field) {
method filterDuplicateText (line 65) | filterDuplicateText(enable) {
method sourceFields (line 86) | sourceFields(srcFields) {
method missing (line 97) | missing() {
method executionHint (line 108) | executionHint() {
FILE: src/aggregations/bucket-aggregations/terms-aggregation-base.js
class TermsAggregationBase (line 34) | class TermsAggregationBase extends BucketAggregationBase {
method constructor (line 36) | constructor(name, aggType, refUrl, field) {
method format (line 49) | format(fmt) {
method minDocCount (line 64) | minDocCount(minDocCnt) {
method shardMinDocCount (line 80) | shardMinDocCount(minDocCnt) {
method size (line 94) | size(size) {
method shardSize (line 110) | shardSize(size) {
method missing (line 122) | missing(value) {
method include (line 154) | include(clause) {
method exclude (line 186) | exclude(clause) {
method executionHint (line 208) | executionHint(hint) {
FILE: src/aggregations/bucket-aggregations/terms-aggregation.js
constant ES_REF_URL (line 11) | const ES_REF_URL =
class TermsAggregation (line 39) | class TermsAggregation extends TermsAggregationBase {
method constructor (line 41) | constructor(name, field) {
method showTermDocCountError (line 53) | showTermDocCountError(enable) {
method includePartition (line 79) | includePartition(partition, numPartitions) {
method collectMode (line 102) | collectMode(mode) {
method order (line 155) | order(key, direction = 'desc') {
FILE: src/aggregations/bucket-aggregations/variable-width-histogram-aggregation.js
class VariableWidthHistogramAggregation (line 26) | class VariableWidthHistogramAggregation extends BucketAggregationBase {
method constructor (line 28) | constructor(name, field, buckets) {
method buckets (line 39) | buckets(buckets) {
FILE: src/aggregations/matrix-aggregations/matrix-stats-aggregation.js
class MatrixStatsAggregation (line 24) | class MatrixStatsAggregation extends Aggregation {
method constructor (line 26) | constructor(name, fields) {
method fields (line 43) | fields(fields) {
method mode (line 56) | mode(mode) {
method missing (line 76) | missing(missing) {
FILE: src/aggregations/metrics-aggregations/avg-aggregation.js
class AvgAggregation (line 43) | class AvgAggregation extends MetricsAggregationBase {
method constructor (line 45) | constructor(name, field) {
FILE: src/aggregations/metrics-aggregations/cardinality-aggregation.js
constant ES_REF_URL (line 5) | const ES_REF_URL =
class CardinalityAggregation (line 33) | class CardinalityAggregation extends MetricsAggregationBase {
method constructor (line 35) | constructor(name, field) {
method format (line 43) | format() {
method precisionThreshold (line 64) | precisionThreshold(threshold) {
FILE: src/aggregations/metrics-aggregations/extended-stats-aggregation.js
class ExtendedStatsAggregation (line 42) | class ExtendedStatsAggregation extends MetricsAggregationBase {
method constructor (line 44) | constructor(name, field) {
method sigma (line 60) | sigma(sigma) {
FILE: src/aggregations/metrics-aggregations/geo-bounds-aggregation.js
constant ES_REF_URL (line 5) | const ES_REF_URL =
class GeoBoundsAggregation (line 22) | class GeoBoundsAggregation extends MetricsAggregationBase {
method constructor (line 24) | constructor(name, field) {
method format (line 34) | format() {
method script (line 43) | script() {
method wrapLongitude (line 55) | wrapLongitude(allowOverlap) {
FILE: src/aggregations/metrics-aggregations/geo-centroid-aggregation.js
constant ES_REF_URL (line 5) | const ES_REF_URL =
class GeoCentroidAggregation (line 32) | class GeoCentroidAggregation extends MetricsAggregationBase {
method constructor (line 34) | constructor(name, field) {
method format (line 42) | format() {
FILE: src/aggregations/metrics-aggregations/max-aggregation.js
class MaxAggregation (line 39) | class MaxAggregation extends MetricsAggregationBase {
method constructor (line 41) | constructor(name, field) {
FILE: src/aggregations/metrics-aggregations/metrics-aggregation-base.js
class MetricsAggregationBase (line 25) | class MetricsAggregationBase extends Aggregation {
method constructor (line 27) | constructor(name, aggType, field) {
method field (line 44) | field(field) {
method script (line 70) | script(script) {
method missing (line 87) | missing(value) {
method format (line 98) | format(fmt) {
FILE: src/aggregations/metrics-aggregations/min-aggregation.js
class MinAggregation (line 39) | class MinAggregation extends MetricsAggregationBase {
method constructor (line 41) | constructor(name, field) {
FILE: src/aggregations/metrics-aggregations/percentile-ranks-aggregation.js
constant ES_REF_URL (line 11) | const ES_REF_URL =
class PercentileRanksAggregation (line 50) | class PercentileRanksAggregation extends MetricsAggregationBase {
method constructor (line 52) | constructor(name, field, values) {
method format (line 62) | format() {
method keyed (line 83) | keyed(keyed) {
method values (line 95) | values(values) {
method tdigest (line 113) | tdigest(compression) {
method compression (line 132) | compression(compression) {
method hdr (line 155) | hdr(numberOfSigDigits) {
FILE: src/aggregations/metrics-aggregations/percentiles-aggregation.js
class PercentilesAggregation (line 36) | class PercentilesAggregation extends MetricsAggregationBase {
method constructor (line 38) | constructor(name, field) {
method keyed (line 55) | keyed(keyed) {
method percents (line 75) | percents(percents) {
method tdigest (line 99) | tdigest(compression) {
method compression (line 124) | compression(compression) {
method hdr (line 146) | hdr(numberOfSigDigits) {
FILE: src/aggregations/metrics-aggregations/scripted-metric-aggregation.js
constant ES_REF_URL (line 5) | const ES_REF_URL =
class ScriptedMetricAggregation (line 45) | class ScriptedMetricAggregation extends MetricsAggregationBase {
method constructor (line 47) | constructor(name) {
method field (line 55) | field() {
method script (line 64) | script() {
method missing (line 73) | missing() {
method initScript (line 88) | initScript(initScript) {
method mapScript (line 102) | mapScript(mapScript) {
method combineScript (line 117) | combineScript(combineScript) {
method reduceScript (line 133) | reduceScript(reduceScript) {
method params (line 149) | params(params) {
FILE: src/aggregations/metrics-aggregations/stats-aggregation.js
class StatsAggregation (line 42) | class StatsAggregation extends MetricsAggregationBase {
method constructor (line 44) | constructor(name, field) {
FILE: src/aggregations/metrics-aggregations/sum-aggregation.js
class SumAggregation (line 52) | class SumAggregation extends MetricsAggregationBase {
method constructor (line 59) | constructor(name, field) {
FILE: src/aggregations/metrics-aggregations/top-hits-aggregation.js
constant ES_REF_URL (line 10) | const ES_REF_URL =
class TopHitsAggregation (line 57) | class TopHitsAggregation extends MetricsAggregationBase {
method constructor (line 59) | constructor(name) {
method field (line 67) | field() {
method script (line 76) | script() {
method missing (line 85) | missing() {
method format (line 94) | format() {
method from (line 105) | from(from) {
method size (line 116) | size(size) {
method sort (line 131) | sort(sort) {
method sorts (line 149) | sorts(sorts) {
method trackScores (line 161) | trackScores(trackScores) {
method version (line 172) | version(version) {
method explain (line 183) | explain(explain) {
method highlight (line 194) | highlight(highlight) {
method source (line 211) | source(source) {
method storedFields (line 226) | storedFields(fields) {
method scriptField (line 238) | scriptField(scriptFieldName, script) {
method scriptFields (line 253) | scriptFields(scriptFields) {
method docvalueFields (line 270) | docvalueFields(fields) {
FILE: src/aggregations/metrics-aggregations/value-count-aggregation.js
constant ES_REF_URL (line 5) | const ES_REF_URL =
class ValueCountAggregation (line 33) | class ValueCountAggregation extends MetricsAggregationBase {
method constructor (line 35) | constructor(name, field) {
method format (line 43) | format() {
FILE: src/aggregations/metrics-aggregations/weighted-average-aggregation.js
constant ES_REF_URL (line 7) | const ES_REF_URL =
class WeightedAverageAggregation (line 47) | class WeightedAverageAggregation extends MetricsAggregationBase {
method constructor (line 55) | constructor(name, value, weight) {
method value (line 79) | value(value, missing) {
method weight (line 113) | weight(weight, missing) {
method script (line 143) | script() {
method missing (line 154) | missing() {
method field (line 165) | field() {
FILE: src/aggregations/pipeline-aggregations/avg-bucket-aggregation.js
constant ES_REF_URL (line 5) | const ES_REF_URL =
class AvgBucketAggregation (line 35) | class AvgBucketAggregation extends PipelineAggregationBase {
method constructor (line 37) | constructor(name, bucketsPath) {
FILE: src/aggregations/pipeline-aggregations/bucket-script-aggregation.js
constant ES_REF_URL (line 5) | const ES_REF_URL =
class BucketScriptAggregation (line 42) | class BucketScriptAggregation extends PipelineAggregationBase {
method constructor (line 44) | constructor(name, bucketsPath) {
method script (line 55) | script(script) {
FILE: src/aggregations/pipeline-aggregations/bucket-selector-aggregation.js
constant ES_REF_URL (line 5) | const ES_REF_URL =
class BucketSelectorAggregation (line 50) | class BucketSelectorAggregation extends PipelineAggregationBase {
method constructor (line 52) | constructor(name, bucketsPath) {
method format (line 60) | format() {
method script (line 72) | script(script) {
FILE: src/aggregations/pipeline-aggregations/bucket-sort-aggregation.js
constant ES_REF_URL (line 5) | const ES_REF_URL =
class BucketSortAggregation (line 33) | class BucketSortAggregation extends PipelineAggregationBase {
method constructor (line 35) | constructor(name) {
method sort (line 45) | sort(sort) {
method from (line 56) | from(from) {
method size (line 67) | size(size) {
FILE: src/aggregations/pipeline-aggregations/cumulative-sum-aggregation.js
constant ES_REF_URL (line 5) | const ES_REF_URL =
class CumulativeSumAggregation (line 30) | class CumulativeSumAggregation extends PipelineAggregationBase {
method constructor (line 32) | constructor(name, bucketsPath) {
method gapPolicy (line 40) | gapPolicy() {
FILE: src/aggregations/pipeline-aggregations/derivative-aggregation.js
constant ES_REF_URL (line 5) | const ES_REF_URL =
class DerivativeAggregation (line 43) | class DerivativeAggregation extends PipelineAggregationBase {
method constructor (line 45) | constructor(name, bucketsPath) {
method unit (line 67) | unit(unit) {
FILE: src/aggregations/pipeline-aggregations/extended-stats-bucket-aggregation.js
constant ES_REF_URL (line 5) | const ES_REF_URL =
class ExtendedStatsBucketAggregation (line 37) | class ExtendedStatsBucketAggregation extends PipelineAggregationBase {
method constructor (line 39) | constructor(name, bucketsPath) {
method sigma (line 50) | sigma(sigma) {
FILE: src/aggregations/pipeline-aggregations/max-bucket-aggregation.js
constant ES_REF_URL (line 5) | const ES_REF_URL =
class MaxBucketAggregation (line 40) | class MaxBucketAggregation extends PipelineAggregationBase {
method constructor (line 42) | constructor(name, bucketsPath) {
FILE: src/aggregations/pipeline-aggregations/min-bucket-aggregation.js
constant ES_REF_URL (line 5) | const ES_REF_URL =
class MinBucketAggregation (line 40) | class MinBucketAggregation extends PipelineAggregationBase {
method constructor (line 42) | constructor(name, bucketsPath) {
FILE: src/aggregations/pipeline-aggregations/moving-average-aggregation.js
constant ES_REF_URL (line 12) | const ES_REF_URL =
class MovingAverageAggregation (line 59) | class MovingAverageAggregation extends PipelineAggregationBase {
method constructor (line 61) | constructor(name, bucketsPath) {
method format (line 69) | format() {
method model (line 94) | model(model) {
method window (line 115) | window(window) {
method minimize (line 136) | minimize(enable) {
method settings (line 154) | settings(settings) {
method predict (line 173) | predict(predict) {
FILE: src/aggregations/pipeline-aggregations/moving-function-aggregation.js
constant ES_REF_URL (line 7) | const ES_REF_URL =
class MovingFunctionAggregation (line 58) | class MovingFunctionAggregation extends PipelineAggregationBase {
method constructor (line 60) | constructor(name, bucketsPath, window, script) {
method window (line 77) | window(window) {
method shift (line 92) | shift(shift) {
method script (line 107) | script(script) {
FILE: src/aggregations/pipeline-aggregations/percentiles-bucket-aggregation.js
constant ES_REF_URL (line 9) | const ES_REF_URL =
class PercentilesBucketAggregation (line 41) | class PercentilesBucketAggregation extends PipelineAggregationBase {
method constructor (line 43) | constructor(name, bucketsPath) {
method percents (line 53) | percents(percents) {
FILE: src/aggregations/pipeline-aggregations/pipeline-aggregation-base.js
class PipelineAggregationBase (line 36) | class PipelineAggregationBase extends Aggregation {
method constructor (line 38) | constructor(name, aggType, refUrl, bucketsPath) {
method bucketsPath (line 69) | bucketsPath(path) {
method gapPolicy (line 82) | gapPolicy(policy) {
method format (line 100) | format(fmt) {
FILE: src/aggregations/pipeline-aggregations/serial-differencing-aggregation.js
constant ES_REF_URL (line 5) | const ES_REF_URL =
class SerialDifferencingAggregation (line 36) | class SerialDifferencingAggregation extends PipelineAggregationBase {
method constructor (line 38) | constructor(name, bucketsPath) {
method lag (line 49) | lag(lag) {
FILE: src/aggregations/pipeline-aggregations/stats-bucket-aggregation.js
constant ES_REF_URL (line 5) | const ES_REF_URL =
class StatsBucketAggregation (line 37) | class StatsBucketAggregation extends PipelineAggregationBase {
method constructor (line 39) | constructor(name, bucketsPath) {
FILE: src/aggregations/pipeline-aggregations/sum-bucket-aggregation.js
constant ES_REF_URL (line 5) | const ES_REF_URL =
class SumBucketAggregation (line 36) | class SumBucketAggregation extends PipelineAggregationBase {
method constructor (line 38) | constructor(name, bucketsPath) {
FILE: src/core/aggregation.js
class Aggregation (line 21) | class Aggregation {
method constructor (line 23) | constructor(name, aggType) {
method name (line 43) | name(name) {
method aggregation (line 56) | aggregation(agg) {
method agg (line 74) | agg(agg) {
method aggregations (line 87) | aggregations(aggs) {
method aggs (line 104) | aggs(aggs) {
method meta (line 115) | meta(meta) {
method _aggsName (line 126) | _aggsName() {
method getDSL (line 143) | getDSL() {
method toJSON (line 153) | toJSON() {
FILE: src/core/geo-point.js
class GeoPoint (line 13) | class GeoPoint {
method constructor (line 15) | constructor() {
method _warn (line 28) | _warn(msg) {
method _warnMixedRepr (line 36) | _warnMixedRepr() {
method _checkObjRepr (line 47) | _checkObjRepr() {
method lat (line 61) | lat(lat) {
method lon (line 74) | lon(lon) {
method object (line 89) | object(point) {
method array (line 106) | array(point) {
method string (line 122) | string(point) {
method toJSON (line 135) | toJSON() {
FILE: src/core/geo-shape.js
constant ES_REF_URL (line 8) | const ES_REF_URL =
class GeoShape (line 34) | class GeoShape {
method constructor (line 36) | constructor(type, coords) {
method type (line 56) | type(type) {
method coordinates (line 79) | coordinates(coords) {
method radius (line 98) | radius(radius) {
method toJSON (line 111) | toJSON() {
FILE: src/core/highlight.js
constant ES_REF_URL (line 7) | const ES_REF_URL =
class Highlight (line 72) | class Highlight {
method constructor (line 74) | constructor(fields) {
method _setFieldOption (line 93) | _setFieldOption(field, option, val) {
method field (line 110) | field(field) {
method fields (line 126) | fields(fields) {
method preTags (line 151) | preTags(tags, field) {
method postTags (line 178) | postTags(tags, field) {
method styledTagsSchema (line 197) | styledTagsSchema() {
method scoreOrder (line 214) | scoreOrder(field) {
method fragmentSize (line 234) | fragmentSize(size, field) {
method numberOfFragments (line 255) | numberOfFragments(count, field) {
method noMatchSize (line 279) | noMatchSize(size, field) {
method highlightQuery (line 308) | highlightQuery(query, field) {
method matchedFields (line 342) | matchedFields(fields, field) {
method phraseLimit (line 367) | phraseLimit(limit) {
method encoder (line 380) | encoder(encoder) {
method requireFieldMatch (line 408) | requireFieldMatch(requireFieldMatch, field) {
method boundaryMaxScan (line 421) | boundaryMaxScan(count, field) {
method boundaryChars (line 436) | boundaryChars(charStr, field) {
method type (line 463) | type(type, field) {
method forceSource (line 491) | forceSource(forceSource, field) {
method fragmenter (line 516) | fragmenter(fragmenter, field) {
method toJSON (line 537) | toJSON() {
FILE: src/core/indexed-shape.js
class IndexedShape (line 26) | class IndexedShape {
method constructor (line 28) | constructor(id, type) {
method id (line 41) | id(id) {
method type (line 52) | type(type) {
method index (line 63) | index(index) {
method path (line 75) | path(path) {
method toJSON (line 87) | toJSON() {
FILE: src/core/inner-hits.js
class InnerHits (line 31) | class InnerHits {
method constructor (line 33) | constructor(name) {
method name (line 48) | name(name) {
method from (line 60) | from(from) {
method size (line 72) | size(size) {
method sort (line 85) | sort(sort) {
method sorts (line 102) | sorts(sorts) {
method highlight (line 119) | highlight(highlight) {
method explain (line 132) | explain(enable) {
method source (line 147) | source(source) {
method storedFields (line 158) | storedFields(fields) {
method scriptField (line 170) | scriptField(scriptFieldName, script) {
method scriptFields (line 185) | scriptFields(scriptFields) {
method docvalueFields (line 202) | docvalueFields(fields) {
method version (line 213) | version(enable) {
method toJSON (line 224) | toJSON() {
FILE: src/core/inspect.js
function inspect (line 15) | function inspect(obj, opts) {
function stylizeNoColor (line 46) | function stylizeNoColor(str) {
function stylizeWithColor (line 50) | function stylizeWithColor(str, styleType) {
function formatValue (line 60) | function formatValue(ctx, value, recurseTimes) {
function isArray (line 180) | function isArray(ar) {
function isBoolean (line 184) | function isBoolean(arg) {
function isNull (line 188) | function isNull(arg) {
function isNumber (line 192) | function isNumber(arg) {
function isUndefined (line 196) | function isUndefined(arg) {
function isRegExp (line 200) | function isRegExp(re) {
function isDate (line 204) | function isDate(d) {
function isError (line 208) | function isError(e) {
function isFunction (line 215) | function isFunction(arg) {
function isSet (line 219) | function isSet(s) {
function arrayToHash (line 223) | function arrayToHash(array) {
function formatError (line 233) | function formatError(value) {
function formatSet (line 237) | function formatSet(ctx, set) {
function formatPrimitive (line 252) | function formatPrimitive(ctx, value) {
function formatArray (line 267) | function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
function formatProperty (line 295) | function formatProperty(ctx, value, recurseTimes, visibleKeys, key, arra...
function reduceToSingleString (line 357) | function reduceToSingleString(output, base, braces) {
function objectToString (line 374) | function objectToString(o) {
FILE: src/core/knn.js
class KNN (line 19) | class KNN {
method constructor (line 21) | constructor(field, k, numCandidates) {
method queryVector (line 36) | queryVector(vector) {
method queryVectorBuilder (line 59) | queryVectorBuilder(modelId, modelText) {
method filter (line 94) | filter(queries) {
method boost (line 108) | boost(boost) {
method similarity (line 118) | similarity(similarity) {
method toJSON (line 129) | toJSON() {
FILE: src/core/query.js
class Query (line 15) | class Query {
method constructor (line 17) | constructor(queryType) {
method boost (line 30) | boost(factor) {
method name (line 49) | name(name) {
method getDSL (line 59) | getDSL() {
method toJSON (line 69) | toJSON() {
FILE: src/core/request-body-search.js
constant KNN (line 5) | const Query = require('./query'),
function recMerge (line 25) | function recMerge(arr) {
class RequestBodySearch (line 67) | class RequestBodySearch {
method constructor (line 69) | constructor() {
method query (line 84) | query(query) {
method kNN (line 97) | kNN(knn) {
method agg (line 114) | agg(agg) {
method aggregation (line 125) | aggregation(agg) {
method aggs (line 141) | aggs(aggs) {
method aggregations (line 154) | aggregations(aggs) {
method suggest (line 180) | suggest(suggest) {
method suggestText (line 199) | suggestText(txt) {
method timeout (line 214) | timeout(timeout) {
method from (line 225) | from(from) {
method size (line 238) | size(size) {
method terminateAfter (line 253) | terminateAfter(numberOfDocs) {
method sort (line 278) | sort(sort) {
method sorts (line 306) | sorts(sorts) {
method trackScores (line 329) | trackScores(enable) {
method trackTotalHits (line 344) | trackTotalHits(enableOrLimit) {
method source (line 386) | source(source) {
method storedFields (line 420) | storedFields(fields) {
method runtimeMapping (line 463) | runtimeMapping(runtimeFieldName, runtimeField) {
method runtimeMappings (line 493) | runtimeMappings(runtimeMappings) {
method scriptField (line 534) | scriptField(scriptFieldName, script) {
method scriptFields (line 568) | scriptFields(scriptFields) {
method docvalueFields (line 590) | docvalueFields(fields) {
method postFilter (line 614) | postFilter(filterQuery) {
method highlight (line 647) | highlight(highlight) {
method rescore (line 698) | rescore(rescore) {
method explain (line 726) | explain(enable) {
method version (line 742) | version(enable) {
method indexBoost (line 763) | indexBoost(index, boost) {
method indicesBoost (line 781) | indicesBoost(index, boost) {
method minScore (line 801) | minScore(score) {
method collapse (line 841) | collapse(field, innerHits, maxConcurrentGroupRequests) {
method searchAfter (line 871) | searchAfter(values) {
method toJSON (line 882) | toJSON() {
FILE: src/core/rescore.js
constant ES_REF_URL (line 9) | const ES_REF_URL =
class Rescore (line 53) | class Rescore {
method constructor (line 55) | constructor(windowSize, rescoreQuery) {
method windowSize (line 70) | windowSize(windowSize) {
method rescoreQuery (line 82) | rescoreQuery(rescoreQuery) {
method queryWeight (line 95) | queryWeight(weight) {
method rescoreQueryWeight (line 106) | rescoreQueryWeight(weight) {
method scoreMode (line 118) | scoreMode(mode) {
method toJSON (line 136) | toJSON() {
FILE: src/core/runtime-field.js
class RuntimeField (line 30) | class RuntimeField {
method constructor (line 32) | constructor(type, script) {
method script (line 51) | script(script) {
method type (line 64) | type(type) {
method lang (line 81) | lang(lang) {
method params (line 94) | params(params) {
method toJSON (line 107) | toJSON() {
FILE: src/core/script.js
class Script (line 30) | class Script {
method constructor (line 32) | constructor(type, source) {
method _warn (line 77) | _warn(msg) {
method _checkMixedRepr (line 86) | _checkMixedRepr() {
method inline (line 110) | inline(scriptCode) {
method source (line 128) | source(scriptCode) {
method stored (line 145) | stored(scriptId) {
method id (line 163) | id(scriptId) {
method file (line 182) | file(fileName) {
method lang (line 205) | lang(lang) {
method params (line 216) | params(params) {
method toJSON (line 227) | toJSON() {
FILE: src/core/search-template.js
class SearchTemplate (line 53) | class SearchTemplate {
method constructor (line 55) | constructor(type, source) {
method _warn (line 83) | _warn(msg) {
method _checkMixedRepr (line 92) | _checkMixedRepr() {
method _setSource (line 113) | _setSource(type, source) {
method inline (line 128) | inline(templ) {
method id (line 139) | id(templId) {
method indexed (line 152) | indexed(templId) {
method file (line 173) | file(fileName) {
method params (line 183) | params(params) {
method toJSON (line 194) | toJSON() {
FILE: src/core/sort.js
constant ES_REF_URL (line 10) | const ES_REF_URL =
class Sort (line 37) | class Sort {
method constructor (line 39) | constructor(field, order) {
method order (line 56) | order(order) {
method mode (line 90) | mode(mode) {
method nestedPath (line 118) | nestedPath(path) {
method nestedFilter (line 140) | nestedFilter(filterQuery) {
method nested (line 168) | nested(nested) {
method missing (line 187) | missing(value) {
method unmappedType (line 204) | unmappedType(type) {
method geoDistance (line 228) | geoDistance(geoPoint) {
method distanceType (line 242) | distanceType(type) {
method unit (line 264) | unit(unit) {
method script (line 290) | script(script) {
method type (line 307) | type(type) {
method format (line 320) | format(fmt) {
method reverse (line 331) | reverse(reverse) {
method toJSON (line 342) | toJSON() {
FILE: src/core/suggester.js
class Suggester (line 21) | class Suggester {
method constructor (line 23) | constructor(suggesterType, name, field) {
method field (line 46) | field(field) {
method size (line 57) | size(size) {
method toJSON (line 68) | toJSON() {
FILE: src/core/util.js
function between (line 52) | function between(num, min, max) {
FILE: src/index.d.ts
class RequestBodySearch (line 13) | class RequestBodySearch {
class Query (line 394) | class Query {
class MatchAllQuery (line 430) | class MatchAllQuery extends Query {
class MatchNoneQuery (line 444) | class MatchNoneQuery extends Query {
class FullTextQueryBase (line 465) | class FullTextQueryBase extends Query {
class MonoFieldQueryBase (line 508) | class MonoFieldQueryBase extends FullTextQueryBase {
class MatchQuery (line 534) | class MatchQuery extends MonoFieldQueryBase {
class MatchPhraseQueryBase (line 693) | class MatchPhraseQueryBase extends MonoFieldQueryBase {
class MatchPhraseQuery (line 723) | class MatchPhraseQuery extends MatchPhraseQueryBase {
class MatchPhrasePrefixQuery (line 744) | class MatchPhrasePrefixQuery extends MatchPhraseQueryBase {
class MultiMatchQuery (line 775) | class MultiMatchQuery extends FullTextQueryBase {
class CommonTermsQuery (line 995) | class CommonTermsQuery extends MonoFieldQueryBase {
class QueryStringQueryBase (line 1084) | class QueryStringQueryBase extends FullTextQueryBase {
class QueryStringQuery (line 1160) | class QueryStringQuery extends QueryStringQueryBase {
class SimpleQueryStringQuery (line 1369) | class SimpleQueryStringQuery extends QueryStringQueryBase {
class CombinedFieldsQuery (line 1408) | class CombinedFieldsQuery extends FullTextQueryBase {
class ValueTermQueryBase (line 1505) | class ValueTermQueryBase extends Query {
class TermQuery (line 1541) | class TermQuery extends ValueTermQueryBase {
class TermsQuery (line 1564) | class TermsQuery extends Query {
class TermsSetQuery (line 1667) | class TermsSetQuery extends Query {
class MultiTermQueryBase (line 1746) | class MultiTermQueryBase extends ValueTermQueryBase {}
class RangeQuery (line 1753) | class RangeQuery extends MultiTermQueryBase {
class ExistsQuery (line 1864) | class ExistsQuery extends Query {
class PrefixQuery (line 1889) | class PrefixQuery extends MultiTermQueryBase {
class WildcardQuery (line 1941) | class WildcardQuery extends MultiTermQueryBase {
class RegexpQuery (line 2003) | class RegexpQuery extends MultiTermQueryBase {
class FuzzyQuery (line 2087) | class FuzzyQuery extends MultiTermQueryBase {
class TypeQuery (line 2146) | class TypeQuery extends Query {
class IdsQuery (line 2180) | class IdsQuery extends Query {
class ConstantScoreQuery (line 2227) | class ConstantScoreQuery extends Query {
class BoolQuery (line 2266) | class BoolQuery extends Query {
class DisMaxQuery (line 2359) | class DisMaxQuery extends Query {
class FunctionScoreQuery (line 2396) | class FunctionScoreQuery extends Query {
class BoostingQuery (line 2466) | class BoostingQuery extends Query {
class JoiningQueryBase (line 2525) | class JoiningQueryBase extends Query {
class NestedQuery (line 2575) | class NestedQuery extends JoiningQueryBase {
class HasChildQuery (line 2604) | class HasChildQuery extends JoiningQueryBase {
class HasParentQuery (line 2658) | class HasParentQuery extends JoiningQueryBase {
class ParentIdQuery (line 2712) | class ParentIdQuery extends Query {
class GeoQueryBase (line 2762) | class GeoQueryBase extends Query {
class GeoShapeQuery (line 2804) | class GeoShapeQuery extends GeoQueryBase {
class GeoBoundingBoxQuery (line 2873) | class GeoBoundingBoxQuery extends GeoQueryBase {
class GeoDistanceQuery (line 2962) | class GeoDistanceQuery extends GeoQueryBase {
class GeoPolygonQuery (line 3010) | class GeoPolygonQuery extends GeoQueryBase {
class MoreLikeThisQuery (line 3040) | class MoreLikeThisQuery extends Query {
class ScriptQuery (line 3218) | class ScriptQuery extends Query {
class ScriptScoreQuery (line 3241) | class ScriptScoreQuery extends Query {
class PercolateQuery (line 3280) | class PercolateQuery extends Query {
class DistanceFeatureQuery (line 3398) | class DistanceFeatureQuery extends Query {
class RankFeatureQuery (line 3463) | class RankFeatureQuery extends Query {
class SpanQueryBase (line 3536) | class SpanQueryBase extends Query {}
class SpanTermQuery (line 3545) | class SpanTermQuery extends SpanQueryBase {
class SpanMultiTermQuery (line 3589) | class SpanMultiTermQuery extends SpanQueryBase {
class SpanFirstQuery (line 3616) | class SpanFirstQuery extends SpanQueryBase {
class SpanNearQuery (line 3648) | class SpanNearQuery extends SpanQueryBase {
class SpanOrQuery (line 3686) | class SpanOrQuery extends SpanQueryBase {
class SpanNotQuery (line 3709) | class SpanNotQuery extends SpanQueryBase {
class SpanLittleBigQueryBase (line 3765) | class SpanLittleBigQueryBase extends SpanQueryBase {
class SpanContainingQuery (line 3788) | class SpanContainingQuery extends SpanLittleBigQueryBase {
class SpanWithinQuery (line 3806) | class SpanWithinQuery extends SpanLittleBigQueryBase {
class SpanFieldMaskingQuery (line 3834) | class SpanFieldMaskingQuery extends SpanQueryBase {
class SparseVectorQuery (line 3878) | class SparseVectorQuery extends Query {
class SemanticQuery (line 3972) | class SemanticQuery extends Query {
class KNN (line 4008) | class KNN {
class Aggregation (line 4092) | class Aggregation {
class MetricsAggregationBase (line 4166) | class MetricsAggregationBase extends Aggregation {
class AvgAggregation (line 4210) | class AvgAggregation extends MetricsAggregationBase {
class WeightedAverageAggregation (line 4242) | class WeightedAverageAggregation extends MetricsAggregationBase {
class CardinalityAggregation (line 4312) | class CardinalityAggregation extends MetricsAggregationBase {
class ExtendedStatsAggregation (line 4355) | class ExtendedStatsAggregation extends MetricsAggregationBase {
class GeoBoundsAggregation (line 4391) | class GeoBoundsAggregation extends MetricsAggregationBase {
class GeoCentroidAggregation (line 4434) | class GeoCentroidAggregation extends MetricsAggregationBase {
class MaxAggregation (line 4469) | class MaxAggregation extends MetricsAggregationBase {
class MinAggregation (line 4503) | class MinAggregation extends MetricsAggregationBase {
class PercentilesAggregation (line 4537) | class PercentilesAggregation extends MetricsAggregationBase {
class PercentileRanksAggregation (line 4629) | class PercentileRanksAggregation extends MetricsAggregationBase {
class ScriptedMetricAggregation (line 4710) | class ScriptedMetricAggregation extends MetricsAggregationBase {
class StatsAggregation (line 4806) | class StatsAggregation extends MetricsAggregationBase {
class SumAggregation (line 4841) | class SumAggregation extends MetricsAggregationBase {
class TopHitsAggregation (line 4873) | class TopHitsAggregation extends MetricsAggregationBase {
class ValueCountAggregation (line 5037) | class ValueCountAggregation extends MetricsAggregationBase {
class BucketAggregationBase (line 5078) | class BucketAggregationBase extends Aggregation {
class AdjacencyMatrixAggregation (line 5107) | class AdjacencyMatrixAggregation extends BucketAggregationBase {
class ChildrenAggregation (line 5175) | class ChildrenAggregation extends BucketAggregationBase {
class CompositeAggregation (line 5221) | class CompositeAggregation extends Aggregation {
class ValuesSourceBase (line 5283) | class ValuesSourceBase {
class TermsValuesSource (line 5365) | class TermsValuesSource extends ValuesSourceBase {
class HistogramValuesSource (line 5393) | class HistogramValuesSource extends ValuesSourceBase {
class DateHistogramValuesSource (line 5430) | class DateHistogramValuesSource extends ValuesSourceBase {
class HistogramAggregationBase (line 5525) | class HistogramAggregationBase extends BucketAggregationBase {
class AutoDateHistogramAggregation (line 5648) | class AutoDateHistogramAggregation extends BucketAggregationBase {
class VariableWidthHistogramAggregation (line 5718) | class VariableWidthHistogramAggregation extends BucketAggregationBase {
class DateHistogramAggregation (line 5754) | class DateHistogramAggregation extends HistogramAggregationBase {
class RangeAggregationBase (line 5825) | class RangeAggregationBase extends BucketAggregationBase {
class DateRangeAggregation (line 5886) | class DateRangeAggregation extends RangeAggregationBase {
class DiversifiedSamplerAggregation (line 5929) | class DiversifiedSamplerAggregation extends BucketAggregationBase {
class FilterAggregation (line 5990) | class FilterAggregation extends BucketAggregationBase {
class FiltersAggregation (line 6035) | class FiltersAggregation extends BucketAggregationBase {
class GeoDistanceAggregation (line 6140) | class GeoDistanceAggregation extends RangeAggregationBase {
class GeoHashGridAggregation (line 6212) | class GeoHashGridAggregation extends BucketAggregationBase {
class GeoHexGridAggregation (line 6280) | class GeoHexGridAggregation extends BucketAggregationBase {
class GeoTileGridAggregation (line 6349) | class GeoTileGridAggregation extends BucketAggregationBase {
class GlobalAggregation (line 6474) | class GlobalAggregation extends BucketAggregationBase {
class HistogramAggregation (line 6509) | class HistogramAggregation extends HistogramAggregationBase {
class IpRangeAggregation (line 6535) | class IpRangeAggregation extends RangeAggregationBase {
class MissingAggregation (line 6565) | class MissingAggregation extends BucketAggregationBase {
class NestedAggregation (line 6596) | class NestedAggregation extends BucketAggregationBase {
class ParentAggregation (line 6641) | class ParentAggregation extends BucketAggregationBase {
class RangeAggregation (line 6684) | class RangeAggregation extends RangeAggregationBase {
class RareTermsAggregation (line 6719) | class RareTermsAggregation extends BucketAggregationBase {
class ReverseNestedAggregation (line 6809) | class ReverseNestedAggregation extends BucketAggregationBase {
class SamplerAggregation (line 6862) | class SamplerAggregation extends BucketAggregationBase {
class TermsAggregationBase (line 6913) | class TermsAggregationBase extends BucketAggregationBase {
class SignificantAggregationBase (line 7018) | class SignificantAggregationBase extends TermsAggregationBase {
class SignificantTermsAggregation (line 7100) | class SignificantTermsAggregation extends SignificantAggregationBase {
class SignificantTextAggregation (line 7131) | class SignificantTextAggregation extends SignificantAggregationBase {
class TermsAggregation (line 7192) | class TermsAggregation extends TermsAggregationBase {
class PipelineAggregationBase (line 7266) | class PipelineAggregationBase extends Aggregation {
class AvgBucketAggregation (line 7306) | class AvgBucketAggregation extends PipelineAggregationBase {
class DerivativeAggregation (line 7333) | class DerivativeAggregation extends PipelineAggregationBase {
class MaxBucketAggregation (line 7371) | class MaxBucketAggregation extends PipelineAggregationBase {
class MinBucketAggregation (line 7401) | class MinBucketAggregation extends PipelineAggregationBase {
class SumBucketAggregation (line 7429) | class SumBucketAggregation extends PipelineAggregationBase {
class StatsBucketAggregation (line 7456) | class StatsBucketAggregation extends PipelineAggregationBase {
class ExtendedStatsBucketAggregation (line 7484) | class ExtendedStatsBucketAggregation extends PipelineAggregationBase {
class PercentilesBucketAggregation (line 7520) | class PercentilesBucketAggregation extends PipelineAggregationBase {
class MovingAverageAggregation (line 7555) | class MovingAverageAggregation extends PipelineAggregationBase {
class MovingFunctionAggregation (line 7637) | class MovingFunctionAggregation extends PipelineAggregationBase {
class CumulativeSumAggregation (line 7696) | class CumulativeSumAggregation extends PipelineAggregationBase {
class BucketScriptAggregation (line 7730) | class BucketScriptAggregation extends PipelineAggregationBase {
class BucketSelectorAggregation (line 7767) | class BucketSelectorAggregation extends PipelineAggregationBase {
class BucketSortAggregation (line 7809) | class BucketSortAggregation extends PipelineAggregationBase {
class SerialDifferencingAggregation (line 7854) | class SerialDifferencingAggregation extends PipelineAggregationBase {
class MatrixStatsAggregation (line 7887) | class MatrixStatsAggregation extends Aggregation {
class ScoreFunction (line 7939) | class ScoreFunction {
class ScriptScoreFunction (line 7973) | class ScriptScoreFunction extends ScoreFunction {
class WeightScoreFunction (line 8002) | class WeightScoreFunction extends ScoreFunction {
class RandomScoreFunction (line 8030) | class RandomScoreFunction extends ScoreFunction {
class FieldValueFactorFunction (line 8055) | class FieldValueFactorFunction extends ScoreFunction {
class DecayScoreFunction (line 8130) | class DecayScoreFunction extends ScoreFunction {
class Suggester (line 8239) | class Suggester {
class AnalyzedSuggesterBase (line 8284) | class AnalyzedSuggesterBase extends Suggester {
class TermSuggester (line 8337) | class TermSuggester extends AnalyzedSuggesterBase {
class DirectGenerator (line 8497) | class DirectGenerator {
class PhraseSuggester (line 8663) | class PhraseSuggester extends AnalyzedSuggesterBase {
class CompletionSuggester (line 8846) | class CompletionSuggester extends Suggester {
class Highlight (line 8999) | class Highlight {
class RuntimeField (line 9235) | class RuntimeField {
class Script (line 9307) | class Script {
class GeoPoint (line 9408) | class GeoPoint {
class GeoShape (line 9472) | class GeoShape {
class IndexedShape (line 9565) | class IndexedShape {
class Sort (line 9626) | class Sort {
class Rescore (line 9890) | class Rescore {
class InnerHits (line 9961) | class InnerHits {
class SearchTemplate (line 10107) | class SearchTemplate {
FILE: src/queries/compound-queries/bool-query.js
class BoolQuery (line 31) | class BoolQuery extends Query {
method constructor (line 33) | constructor() {
method _addQuery (line 45) | _addQuery(clause, query) {
method _addQueries (line 59) | _addQueries(clause, queries) {
method must (line 75) | must(queries) {
method filter (line 99) | filter(queries) {
method mustNot (line 115) | mustNot(queries) {
method should (line 131) | should(queries) {
method disableCoord (line 146) | disableCoord(enable) {
method minimumShouldMatch (line 162) | minimumShouldMatch(minimumShouldMatch) {
method adjustPureNegative (line 174) | adjustPureNegative(enable) {
method toJSON (line 186) | toJSON() {
FILE: src/queries/compound-queries/boosting-query.js
class BoostingQuery (line 31) | class BoostingQuery extends Query {
method constructor (line 33) | constructor(positiveQry, negativeQry, negativeBoost) {
method positive (line 48) | positive(query) {
method negative (line 62) | negative(query) {
method negativeBoost (line 75) | negativeBoost(factor) {
FILE: src/queries/compound-queries/constant-score-query.js
class ConstantScoreQuery (line 27) | class ConstantScoreQuery extends Query {
method constructor (line 29) | constructor(filterQuery) {
method filter (line 41) | filter(filterQuery) {
method query (line 57) | query(filterQuery) {
FILE: src/queries/compound-queries/dis-max-query.js
class DisMaxQuery (line 32) | class DisMaxQuery extends Query {
method constructor (line 34) | constructor() {
method _addQuery (line 45) | _addQuery(query) {
method tieBreaker (line 61) | tieBreaker(factor) {
method queries (line 72) | queries(queries) {
FILE: src/queries/compound-queries/function-score-query.js
constant ES_REF_URL (line 13) | const ES_REF_URL =
class FunctionScoreQuery (line 75) | class FunctionScoreQuery extends Query {
method constructor (line 77) | constructor() {
method query (line 89) | query(query) {
method scoreMode (line 103) | scoreMode(mode) {
method boostMode (line 122) | boostMode(mode) {
method maxBoost (line 140) | maxBoost(limit) {
method minScore (line 151) | minScore(limit) {
method function (line 162) | function(func) {
method functions (line 175) | functions(funcs) {
FILE: src/queries/compound-queries/score-functions/decay-score-function.js
constant ES_REF_URL (line 9) | const ES_REF_URL =
class DecayScoreFunction (line 54) | class DecayScoreFunction extends ScoreFunction {
method constructor (line 56) | constructor(mode = 'gauss', field) {
method mode (line 69) | mode(mode) {
method linear (line 91) | linear() {
method exp (line 102) | exp() {
method gauss (line 113) | gauss() {
method field (line 124) | field(field) {
method origin (line 138) | origin(origin) {
method scale (line 153) | scale(scale) {
method offset (line 165) | offset(offset) {
method decay (line 177) | decay(decay) {
method toJSON (line 189) | toJSON() {
FILE: src/queries/compound-queries/score-functions/field-value-factor-function.js
constant ES_REF_URL (line 12) | const ES_REF_URL =
class FieldValueFactorFunction (line 40) | class FieldValueFactorFunction extends ScoreFunction {
method constructor (line 42) | constructor(field) {
method field (line 54) | field(field) {
method factor (line 65) | factor(factor) {
method modifier (line 80) | modifier(mod) {
method missing (line 99) | missing(val) {
FILE: src/queries/compound-queries/score-functions/random-score-function.js
class RandomScoreFunction (line 16) | class RandomScoreFunction extends ScoreFunction {
method constructor (line 18) | constructor() {
method seed (line 28) | seed(seed) {
FILE: src/queries/compound-queries/score-functions/score-function.js
class ScoreFunction (line 20) | class ScoreFunction {
method constructor (line 22) | constructor(name) {
method filter (line 37) | filter(filterQry) {
method weight (line 50) | weight(weight) {
method toJSON (line 62) | toJSON() {
FILE: src/queries/compound-queries/score-functions/script-score-function.js
class ScriptScoreFunction (line 35) | class ScriptScoreFunction extends ScoreFunction {
method constructor (line 37) | constructor(script) {
method script (line 48) | script(script) {
FILE: src/queries/compound-queries/score-functions/weight-score-function.js
class WeightScoreFunction (line 25) | class WeightScoreFunction extends ScoreFunction {
method constructor (line 27) | constructor(weight) {
method toJSON (line 49) | toJSON() {
FILE: src/queries/full-text-queries/combined-fields-query.js
constant ES_REF_URL (line 10) | const ES_REF_URL =
class CombinedFieldsQuery (line 37) | class CombinedFieldsQuery extends FullTextQueryBase {
method constructor (line 39) | constructor(fields, queryString) {
method field (line 61) | field(field) {
method fields (line 82) | fields(fields) {
method autoGenerateSynonymsPhraseQuery (line 95) | autoGenerateSynonymsPhraseQuery(enable) {
method operator (line 108) | operator(operator) {
method zeroTermsQuery (line 134) | zeroTermsQuery(behavior) {
FILE: src/queries/full-text-queries/common-terms-query.js
constant ES_REF_URL (line 11) | const ES_REF_URL =
class CommonTermsQuery (line 41) | class CommonTermsQuery extends MonoFieldQueryBase {
method constructor (line 43) | constructor(field, queryString) {
method _warn (line 53) | _warn(msg) {
method _warnMixedRepr (line 61) | _warnMixedRepr() {
method _checkMinMatchRepr (line 72) | _checkMinMatchRepr() {
method cutoffFrequency (line 92) | cutoffFrequency(frequency) {
method lowFreqOperator (line 110) | lowFreqOperator(operator) {
method highFreqOperator (line 130) | highFreqOperator(operator) {
method lowFreq (line 156) | lowFreq(lowFreqMinMatch) {
method highFreq (line 177) | highFreq(highFreqMinMatch) {
method disableCoord (line 194) | disableCoord(enable) {
FILE: src/queries/full-text-queries/full-text-query-base.js
class FullTextQueryBase (line 20) | class FullTextQueryBase extends Query {
method constructor (line 29) | constructor(queryType, queryString) {
method analyzer (line 50) | analyzer(analyzer) {
method minimumShouldMatch (line 71) | minimumShouldMatch(minimumShouldMatch) {
method query (line 87) | query(queryString) {
FILE: src/queries/full-text-queries/match-phrase-prefix-query.js
constant ES_REF_URL (line 5) | const ES_REF_URL =
class MatchPhrasePrefixQuery (line 19) | class MatchPhrasePrefixQuery extends MatchPhraseQueryBase {
method constructor (line 21) | constructor(field, queryString) {
method maxExpansions (line 35) | maxExpansions(limit) {
FILE: src/queries/full-text-queries/match-phrase-query-base.js
class MatchPhraseQueryBase (line 20) | class MatchPhraseQueryBase extends MonoFieldQueryBase {
method constructor (line 22) | constructor(queryType, refUrl, field, queryString) {
method minimumShouldMatch (line 32) | minimumShouldMatch() {
method slop (line 46) | slop(slop) {
FILE: src/queries/full-text-queries/match-phrase-query.js
constant ES_REF_URL (line 5) | const ES_REF_URL =
class MatchPhraseQuery (line 22) | class MatchPhraseQuery extends MatchPhraseQueryBase {
method constructor (line 24) | constructor(field, queryString) {
FILE: src/queries/full-text-queries/match-query.js
constant ES_REF_URL (line 11) | const ES_REF_URL =
class MatchQuery (line 42) | class MatchQuery extends MonoFieldQueryBase {
method constructor (line 47) | constructor(field, queryString) {
method operator (line 59) | operator(operator) {
method lenient (line 79) | lenient(enable) {
method fuzziness (line 94) | fuzziness(factor) {
method prefixLength (line 105) | prefixLength(len) {
method maxExpansions (line 116) | maxExpansions(limit) {
method rewrite (line 156) | rewrite(method) {
method fuzzyRewrite (line 198) | fuzzyRewrite(method) {
method fuzzyTranspositions (line 211) | fuzzyTranspositions(enable) {
method zeroTermsQuery (line 230) | zeroTermsQuery(behavior) {
method cutoffFrequency (line 256) | cutoffFrequency(frequency) {
FILE: src/queries/full-text-queries/mono-field-query-base.js
class MonoFieldQueryBase (line 21) | class MonoFieldQueryBase extends FullTextQueryBase {
method constructor (line 23) | constructor(queryType, field, queryString) {
method field (line 35) | field(field) {
method toJSON (line 47) | toJSON() {
FILE: src/queries/full-text-queries/multi-match-query.js
constant ES_REF_URL (line 12) | const ES_REF_URL =
class MultiMatchQuery (line 44) | class MultiMatchQuery extends FullTextQueryBase {
method constructor (line 50) | constructor(fields, queryString) {
method field (line 72) | field(field) {
method fields (line 93) | fields(fields) {
method type (line 151) | type(type) {
method tieBreaker (line 171) | tieBreaker(factor) {
method operator (line 184) | operator(operator) {
method lenient (line 204) | lenient(enable) {
method slop (line 219) | slop(slop) {
method fuzziness (line 237) | fuzziness(factor) {
method prefixLength (line 248) | prefixLength(len) {
method maxExpansions (line 259) | maxExpansions(limit) {
method rewrite (line 299) | rewrite(method) {
method fuzzyRewrite (line 341) | fuzzyRewrite(method) {
method zeroTermsQuery (line 357) | zeroTermsQuery(behavior) {
method cutoffFrequency (line 379) | cutoffFrequency(frequency) {
FILE: src/queries/full-text-queries/query-string-query-base.js
class QueryStringQueryBase (line 29) | class QueryStringQueryBase extends FullTextQueryBase {
method constructor (line 31) | constructor(queryType, refUrl, queryString) {
method field (line 55) | field(field) {
method fields (line 80) | fields(fields) {
method defaultOperator (line 98) | defaultOperator(operator) {
method analyzeWildcard (line 117) | analyzeWildcard(enable) {
method lenient (line 130) | lenient(enable) {
method quoteFieldSuffix (line 142) | quoteFieldSuffix(suffix) {
method allFields (line 155) | allFields(enable) {
FILE: src/queries/full-text-queries/query-string-query.js
constant ES_REF_URL (line 6) | const ES_REF_URL =
class QueryStringQuery (line 22) | class QueryStringQuery extends QueryStringQueryBase {
method constructor (line 24) | constructor(queryString) {
method defaultField (line 36) | defaultField(field) {
method allowLeadingWildcard (line 47) | allowLeadingWildcard(enable) {
method enablePositionIncrements (line 58) | enablePositionIncrements(enable) {
method fuzzyMaxExpansions (line 69) | fuzzyMaxExpansions(limit) {
method fuzziness (line 84) | fuzziness(factor) {
method fuzzyPrefixLength (line 95) | fuzzyPrefixLength(len) {
method rewrite (line 135) | rewrite(method) {
method fuzzyRewrite (line 177) | fuzzyRewrite(method) {
method phraseSlop (line 191) | phraseSlop(slop) {
method autoGeneratePhraseQueries (line 205) | autoGeneratePhraseQueries(enable) {
method maxDeterminizedStates (line 218) | maxDeterminizedStates(limit) {
method timeZone (line 229) | timeZone(zone) {
method splitOnWhitespace (line 247) | splitOnWhitespace(enable) {
method useDisMax (line 268) | useDisMax(enable) {
method tieBreaker (line 279) | tieBreaker(factor) {
method quoteAnalyzer (line 291) | quoteAnalyzer(analyzer) {
method escape (line 302) | escape(enable) {
FILE: src/queries/full-text-queries/simple-query-string-query.js
constant ES_REF_URL (line 5) | const ES_REF_URL =
class SimpleQueryStringQuery (line 27) | class SimpleQueryStringQuery extends QueryStringQueryBase {
method constructor (line 29) | constructor(queryString) {
method flags (line 46) | flags(flags) {
FILE: src/queries/geo-queries/geo-bounding-box-query.js
constant ES_REF_URL (line 12) | const ES_REF_URL =
class GeoBoundingBoxQuery (line 55) | class GeoBoundingBoxQuery extends GeoQueryBase {
method constructor (line 57) | constructor(field) {
method topLeft (line 68) | topLeft(point) {
method bottomRight (line 82) | bottomRight(point) {
method topRight (line 96) | topRight(point) {
method bottomLeft (line 110) | bottomLeft(point) {
method top (line 123) | top(val) {
method left (line 134) | left(val) {
method bottom (line 145) | bottom(val) {
method right (line 156) | right(val) {
method type (line 183) | type(type) {
FILE: src/queries/geo-queries/geo-distance-query.js
constant ES_REF_URL (line 12) | const ES_REF_URL =
class GeoDistanceQuery (line 40) | class GeoDistanceQuery extends GeoQueryBase {
method constructor (line 42) | constructor(field, point) {
method distance (line 56) | distance(distance) {
method distanceType (line 70) | distanceType(type) {
method geoPoint (line 88) | geoPoint(point) {
FILE: src/queries/geo-queries/geo-polygon-query.js
class GeoPolygonQuery (line 26) | class GeoPolygonQuery extends GeoQueryBase {
method constructor (line 28) | constructor(field) {
method points (line 65) | points(points) {
FILE: src/queries/geo-queries/geo-query-base.js
class GeoQueryBase (line 29) | class GeoQueryBase extends Query {
method constructor (line 31) | constructor(queryType, field) {
method field (line 46) | field(field) {
method validationMethod (line 64) | validationMethod(method) {
method toJSON (line 87) | toJSON() {
FILE: src/queries/geo-queries/geo-shape-query.js
constant ES_REF_URL (line 14) | const ES_REF_URL =
class GeoShapeQuery (line 59) | class GeoShapeQuery extends GeoQueryBase {
method constructor (line 61) | constructor(field) {
method validationMethod (line 69) | validationMethod() {
method shape (line 81) | shape(shape) {
method indexedShape (line 95) | indexedShape(shape) {
method relation (line 110) | relation(relation) {
method ignoreUnmapped (line 130) | ignoreUnmapped(enable) {
FILE: src/queries/joining-queries/has-child-query.js
constant ES_REF_URL (line 7) | const ES_REF_URL =
class HasChildQuery (line 39) | class HasChildQuery extends JoiningQueryBase {
method constructor (line 41) | constructor(qry, type) {
method type (line 54) | type(type) {
method childType (line 65) | childType(type) {
method minChildren (line 85) | minChildren(limit) {
method maxChildren (line 103) | maxChildren(limit) {
FILE: src/queries/joining-queries/has-parent-query.js
constant ES_REF_URL (line 7) | const ES_REF_URL =
class HasParentQuery (line 37) | class HasParentQuery extends JoiningQueryBase {
method constructor (line 39) | constructor(qry, type) {
method scoreMode (line 49) | scoreMode() {
method type (line 62) | type(type) {
method parentType (line 72) | parentType(type) {
method score (line 93) | score(enable) {
FILE: src/queries/joining-queries/joining-query-base.js
class JoiningQueryBase (line 31) | class JoiningQueryBase extends Query {
method constructor (line 33) | constructor(queryType, refUrl, qry) {
method query (line 46) | query(qry) {
method scoreMode (line 73) | scoreMode(mode) {
method ignoreUnmapped (line 93) | ignoreUnmapped(enable) {
method innerHits (line 104) | innerHits(innerHits) {
FILE: src/queries/joining-queries/nested-query.js
constant ES_REF_URL (line 7) | const ES_REF_URL =
class NestedQuery (line 33) | class NestedQuery extends JoiningQueryBase {
method constructor (line 35) | constructor(qry, path) {
method path (line 47) | path(path) {
FILE: src/queries/joining-queries/parent-id-query.js
class ParentIdQuery (line 20) | class ParentIdQuery extends Query {
method constructor (line 22) | constructor(type, id) {
method type (line 35) | type(type) {
method id (line 46) | id(id) {
method ignoreUnmapped (line 59) | ignoreUnmapped(enable) {
FILE: src/queries/match-all-query.js
class MatchAllQuery (line 15) | class MatchAllQuery extends Query {
method constructor (line 17) | constructor() {
FILE: src/queries/match-none-query.js
class MatchNoneQuery (line 15) | class MatchNoneQuery extends Query {
method constructor (line 17) | constructor() {
FILE: src/queries/span-queries/span-containing-query.js
class SpanContainingQuery (line 26) | class SpanContainingQuery extends SpanLittleBigQueryBase {
method constructor (line 28) | constructor() {
FILE: src/queries/span-queries/span-field-masking-query.js
class SpanFieldMaskingQuery (line 42) | class SpanFieldMaskingQuery extends SpanQueryBase {
method constructor (line 44) | constructor(field, spanQry) {
method query (line 57) | query(spanQry) {
method field (line 70) | field(field) {
FILE: src/queries/span-queries/span-first-query.js
class SpanFirstQuery (line 25) | class SpanFirstQuery extends SpanQueryBase {
method constructor (line 27) | constructor(spanQry) {
method match (line 39) | match(spanQry) {
method end (line 52) | end(limit) {
FILE: src/queries/span-queries/span-little-big-query-base.js
class SpanLittleBigQueryBase (line 18) | class SpanLittleBigQueryBase extends SpanQueryBase {
method little (line 25) | little(spanQry) {
method big (line 38) | big(spanQry) {
FILE: src/queries/span-queries/span-multi-term-query.js
class SpanMultiTermQuery (line 27) | class SpanMultiTermQuery extends SpanQueryBase {
method constructor (line 29) | constructor(multiTermQry) {
method match (line 41) | match(multiTermQry) {
FILE: src/queries/span-queries/span-near-query.js
class SpanNearQuery (line 28) | class SpanNearQuery extends SpanQueryBase {
method constructor (line 30) | constructor() {
method clauses (line 42) | clauses(clauses) {
method slop (line 57) | slop(slop) {
method inOrder (line 69) | inOrder(enable) {
FILE: src/queries/span-queries/span-not-query.js
class SpanNotQuery (line 28) | class SpanNotQuery extends SpanQueryBase {
method constructor (line 30) | constructor() {
method include (line 40) | include(spanQry) {
method exclude (line 54) | exclude(spanQry) {
method pre (line 68) | pre(pre) {
method post (line 79) | post(post) {
method dist (line 91) | dist(dist) {
FILE: src/queries/span-queries/span-or-query.js
class SpanOrQuery (line 24) | class SpanOrQuery extends SpanQueryBase {
method constructor (line 26) | constructor() {
method clauses (line 38) | clauses(clauses) {
FILE: src/queries/span-queries/span-query-base.js
class SpanQueryBase (line 14) | class SpanQueryBase extends Query {}
FILE: src/queries/span-queries/span-term-query.js
class SpanTermQuery (line 26) | class SpanTermQuery extends SpanQueryBase {
method constructor (line 31) | constructor(field, value) {
method field (line 44) | field(field) {
method value (line 55) | value(queryVal) {
method toJSON (line 67) | toJSON() {
FILE: src/queries/span-queries/span-within-query.js
class SpanWithinQuery (line 26) | class SpanWithinQuery extends SpanLittleBigQueryBase {
method constructor (line 28) | constructor() {
FILE: src/queries/specialized-queries/distance-feature-query.js
class DistanceFeatureQuery (line 24) | class DistanceFeatureQuery extends Query {
method constructor (line 28) | constructor(field) {
method field (line 38) | field(fieldName) {
method origin (line 49) | origin(originPoint) {
method pivot (line 61) | pivot(pivotDistance) {
FILE: src/queries/specialized-queries/more-like-this-query.js
class MoreLikeThisQuery (line 57) | class MoreLikeThisQuery extends Query {
method constructor (line 59) | constructor() {
method _setSearchClause (line 69) | _setSearchClause(clauseType, clauses) {
method fields (line 92) | fields(fields) {
method like (line 120) | like(like) {
method unlike (line 135) | unlike(unlike) {
method likeText (line 149) | likeText(txt) {
method ids (line 164) | ids(ids) {
method docs (line 181) | docs(docs) {
method maxQueryTerms (line 196) | maxQueryTerms(termsLimit) {
method minTermFreq (line 208) | minTermFreq(termFreqLimit) {
method minDocFreq (line 220) | minDocFreq(docFreqLimit) {
method maxDocFreq (line 232) | maxDocFreq(docFreqLimit) {
method minWordLength (line 244) | minWordLength(wordLenLimit) {
method maxWordLength (line 256) | maxWordLength(wordLenLimit) {
method stopWords (line 268) | stopWords(words) {
method analyzer (line 280) | analyzer(analyzer) {
method minimumShouldMatch (line 294) | minimumShouldMatch(minimumShouldMatch) {
method boostTerms (line 306) | boostTerms(boost) {
method include (line 318) | include(enable) {
FILE: src/queries/specialized-queries/percolate-query.js
class PercolateQuery (line 34) | class PercolateQuery extends Query {
method constructor (line 36) | constructor(field, docType) {
method field (line 51) | field(field) {
method documentType (line 65) | documentType(docType) {
method document (line 82) | document(doc) {
method documents (line 99) | documents(docs) {
method index (line 113) | index(index) {
method type (line 125) | type(type) {
method id (line 137) | id(id) {
method routing (line 148) | routing(routing) {
method preference (line 159) | preference(preference) {
method version (line 172) | version(version) {
FILE: src/queries/specialized-queries/rank-feature-query.js
class RankFeatureQuery (line 22) | class RankFeatureQuery extends Query {
method constructor (line 26) | constructor(field) {
method field (line 36) | field(fieldName) {
method linear (line 45) | linear() {
method saturation (line 55) | saturation() {
method saturationPivot (line 65) | saturationPivot(pivot) {
method log (line 78) | log(scalingFactor) {
method sigmoid (line 90) | sigmoid(pivot, exponent) {
FILE: src/queries/specialized-queries/script-query.js
class ScriptQuery (line 29) | class ScriptQuery extends Query {
method constructor (line 31) | constructor(script) {
method script (line 43) | script(script) {
FILE: src/queries/specialized-queries/script-score-query.js
class ScriptScoreQuery (line 23) | class ScriptScoreQuery extends Query {
method constructor (line 25) | constructor() {
method query (line 35) | query(query) {
method script (line 48) | script(script) {
method minScore (line 61) | minScore(limit) {
FILE: src/queries/term-level-queries/exists-query.js
class ExistsQuery (line 22) | class ExistsQuery extends Query {
method constructor (line 24) | constructor(field) {
method field (line 36) | field(field) {
FILE: src/queries/term-level-queries/fuzzy-query.js
class FuzzyQuery (line 31) | class FuzzyQuery extends MultiTermQueryBase {
method constructor (line 33) | constructor(field, value) {
method fuzziness (line 47) | fuzziness(factor) {
method prefixLength (line 59) | prefixLength(len) {
method maxExpansions (line 70) | maxExpansions(limit) {
method transpositions (line 82) | transpositions(enable) {
FILE: src/queries/term-level-queries/ids-query.js
class IdsQuery (line 24) | class IdsQuery extends Query {
method constructor (line 26) | constructor(type, ids) {
method type (line 41) | type(type) {
method values (line 52) | values(ids) {
method ids (line 66) | ids(ids) {
FILE: src/queries/term-level-queries/multi-term-query-base.js
class MultiTermQueryBase (line 21) | class MultiTermQueryBase extends ValueTermQueryBase {}
FILE: src/queries/term-level-queries/prefix-query.js
constant ES_REF_URL (line 6) | const ES_REF_URL =
class PrefixQuery (line 22) | class PrefixQuery extends MultiTermQueryBase {
method constructor (line 24) | constructor(field, value) {
method rewrite (line 63) | rewrite(method) {
FILE: src/queries/term-level-queries/range-query.js
constant ES_REF_URL (line 12) | const ES_REF_URL =
class RangeQuery (line 39) | class RangeQuery extends MultiTermQueryBase {
method constructor (line 41) | constructor(field) {
method value (line 49) | value() {
method gte (line 60) | gte(val) {
method lte (line 71) | lte(val) {
method gt (line 82) | gt(val) {
method lt (line 93) | lt(val) {
method from (line 104) | from(val) {
method to (line 115) | to(val) {
method includeLower (line 126) | includeLower(enable) {
method includeUpper (line 137) | includeUpper(enable) {
method timeZone (line 148) | timeZone(zone) {
method format (line 166) | format(fmt) {
method relation (line 179) | relation(relation) {
method toJSON (line 198) | toJSON() {
FILE: src/queries/term-level-queries/regexp-query.js
constant ES_REF_URL (line 6) | const ES_REF_URL =
class RegexpQuery (line 24) | class RegexpQuery extends MultiTermQueryBase {
method constructor (line 26) | constructor(field, value) {
method flags (line 42) | flags(flags) {
method caseInsensitive (line 58) | caseInsensitive(caseInsensitive) {
method maxDeterminizedStates (line 76) | maxDeterminizedStates(limit) {
method rewrite (line 116) | rewrite(method) {
FILE: src/queries/term-level-queries/term-query.js
class TermQuery (line 19) | class TermQuery extends ValueTermQueryBase {
method constructor (line 21) | constructor(field, queryVal) {
FILE: src/queries/term-level-queries/terms-query.js
class TermsQuery (line 33) | class TermsQuery extends Query {
method constructor (line 37) | constructor(field, values) {
method _setTermsLookupOpt (line 59) | _setTermsLookupOpt(key, val) {
method field (line 70) | field(field) {
method value (line 81) | value(value) {
method values (line 93) | values(values) {
method termsLookup (line 108) | termsLookup(lookupOpts) {
method index (line 128) | index(idx) {
method type (line 139) | type(type) {
method id (line 150) | id(id) {
method path (line 161) | path(path) {
method routing (line 172) | routing(routing) {
method toJSON (line 184) | toJSON() {
FILE: src/queries/term-level-queries/terms-set-query.js
class TermsSetQuery (line 30) | class TermsSetQuery extends Query {
method constructor (line 32) | constructor(field, terms) {
method field (line 50) | field(field) {
method term (line 61) | term(term) {
method terms (line 73) | terms(terms) {
method minimumShouldMatchField (line 86) | minimumShouldMatchField(fieldName) {
method minimumShouldMatchScript (line 107) | minimumShouldMatchScript(script) {
method toJSON (line 119) | toJSON() {
FILE: src/queries/term-level-queries/type-query.js
class TypeQuery (line 19) | class TypeQuery extends Query {
method constructor (line 21) | constructor(type) {
method value (line 33) | value(type) {
method type (line 45) | type(type) {
FILE: src/queries/term-level-queries/value-term-query-base.js
class ValueTermQueryBase (line 17) | class ValueTermQueryBase extends Query {
method constructor (line 19) | constructor(queryType, field, value) {
method field (line 32) | field(field) {
method value (line 43) | value(queryVal) {
method toJSON (line 55) | toJSON() {
method caseInsensitive (line 83) | caseInsensitive(value = true) {
FILE: src/queries/term-level-queries/wildcard-query.js
constant ES_REF_URL (line 6) | const ES_REF_URL =
class WildcardQuery (line 22) | class WildcardQuery extends MultiTermQueryBase {
method constructor (line 24) | constructor(field, value) {
method caseInsensitive (line 39) | caseInsensitive(caseInsensitive) {
method rewrite (line 79) | rewrite(method) {
FILE: src/queries/vector-queries/semantic-query.js
class SemanticQuery (line 20) | class SemanticQuery extends Query {
method constructor (line 22) | constructor(field, query) {
method field (line 33) | field(field) {
method query (line 43) | query(query) {
FILE: src/queries/vector-queries/sparse-vector-query.js
class SparseVectorQuery (line 17) | class SparseVectorQuery extends Query {
method constructor (line 20) | constructor(field) {
method field (line 31) | field(field) {
method inferenceId (line 42) | inferenceId(inferenceId) {
method query (line 54) | query(query) {
method queryVector (line 66) | queryVector(queryVector) {
method prune (line 79) | prune(prune) {
method tokensFreqRatioThreshold (line 92) | tokensFreqRatioThreshold(tokensFreqRatioThreshold) {
method tokensWeightThreshold (line 109) | tokensWeightThreshold(tokensWeightThreshold) {
method onlyScorePrunedTokens (line 126) | onlyScorePrunedTokens(onlyScorePrunedTokens) {
FILE: src/suggesters/analyzed-suggester-base.js
class AnalyzedSuggesterBase (line 26) | class AnalyzedSuggesterBase extends Suggester {
method constructor (line 28) | constructor(suggesterType, name, field, txt) {
method text (line 41) | text(txt) {
method analyzer (line 53) | analyzer(analyzer) {
method shardSize (line 71) | shardSize(size) {
FILE: src/suggesters/completion-suggester.js
class CompletionSuggester (line 43) | class CompletionSuggester extends Suggester {
method constructor (line 45) | constructor(name, field) {
method prefix (line 55) | prefix(prefix) {
method skipDuplicates (line 68) | skipDuplicates(skip = true) {
method _checkFuzzy (line 79) | _checkFuzzy() {
method fuzzy (line 92) | fuzzy(fuzzy = true) {
method fuzziness (line 112) | fuzziness(factor) {
method transpositions (line 126) | transpositions(enable) {
method minLength (line 141) | minLength(len) {
method prefixLength (line 155) | prefixLength(len) {
method unicodeAware (line 171) | unicodeAware(enable) {
method regex (line 188) | regex(expr) {
method flags (line 201) | flags(flags) {
method maxDeterminizedStates (line 217) | maxDeterminizedStates(limit) {
method contexts (line 277) | contexts(name, ctx) {
FILE: src/suggesters/direct-generator.js
constant ES_REF_URL (line 10) | const ES_REF_URL =
class DirectGenerator (line 33) | class DirectGenerator {
method constructor (line 35) | constructor(field) {
method field (line 48) | field(field) {
method size (line 59) | size(size) {
method suggestMode (line 85) | suggestMode(mode) {
method maxEdits (line 106) | maxEdits(maxEdits) {
method prefixLength (line 122) | prefixLength(len) {
method minWordLength (line 135) | minWordLength(len) {
method maxInspections (line 150) | maxInspections(maxInspections) {
method minDocFreq (line 167) | minDocFreq(limit) {
method maxTermFreq (line 186) | maxTermFreq(limit) {
method preFilter (line 200) | preFilter(filter) {
method postFilter (line 213) | postFilter(filter) {
method toJSON (line 224) | toJSON() {
FILE: src/suggesters/phrase-suggester.js
constant ES_REF_URL (line 12) | const ES_REF_URL =
class PhraseSuggester (line 49) | class PhraseSuggester extends AnalyzedSuggesterBase {
method constructor (line 51) | constructor(name, field, txt) {
method gramSize (line 65) | gramSize(size) {
method realWordErrorLikelihood (line 78) | realWordErrorLikelihood(factor) {
method confidence (line 95) | confidence(level) {
method maxErrors (line 115) | maxErrors(limit) {
method separator (line 128) | separator(sep) {
method highlight (line 143) | highlight(preTag, postTag) {
method collate (line 194) | collate(opts) {
method smoothing (line 225) | smoothing(model) {
method directGenerator (line 260) | directGenerator(dirGen) {
method toJSON (line 275) | toJSON() {
FILE: src/suggesters/term-suggester.js
constant ES_REF_URL (line 12) | const ES_REF_URL =
class TermSuggester (line 54) | class TermSuggester extends AnalyzedSuggesterBase {
method constructor (line 56) | constructor(name, field, txt) {
method sort (line 74) | sort(sort) {
method suggestMode (line 101) | suggestMode(mode) {
method maxEdits (line 122) | maxEdits(maxEdits) {
method prefixLength (line 138) | prefixLength(len) {
method minWordLength (line 151) | minWordLength(len) {
method maxInspections (line 166) | maxInspections(maxInspections) {
method minDocFreq (line 183) | minDocFreq(limit) {
method maxTermFreq (line 202) | maxTermFreq(limit) {
method stringDistance (line 227) | stringDistance(implMethod) {
FILE: test/core-test/util.test.js
class TestClass (line 17) | class TestClass {}
method constructor (line 66) | constructor(arg1, arg2) {
method constructor (line 82) | constructor() {
class TestClass (line 23) | class TestClass {}
method constructor (line 66) | constructor(arg1, arg2) {
method constructor (line 82) | constructor() {
class TestClass (line 34) | class TestClass {}
method constructor (line 66) | constructor(arg1, arg2) {
method constructor (line 82) | constructor() {
class TestClass (line 45) | class TestClass {}
method constructor (line 66) | constructor(arg1, arg2) {
method constructor (line 82) | constructor() {
class OtherClass (line 46) | class OtherClass {}
class TestClass (line 55) | class TestClass {}
method constructor (line 66) | constructor(arg1, arg2) {
method constructor (line 82) | constructor() {
class TestClass (line 65) | class TestClass {
method constructor (line 66) | constructor(arg1, arg2) {
method constructor (line 82) | constructor() {
class TestClass (line 81) | class TestClass {
method constructor (line 66) | constructor(arg1, arg2) {
method constructor (line 82) | constructor() {
FILE: test/index.test.js
method toJSON (line 339) | toJSON() {
FILE: vitest.config.js
method onConsoleLog (line 47) | onConsoleLog(log, type) {
Condensed preview — 367 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (1,795K chars).
[
{
"path": ".eslintignore",
"chars": 24,
"preview": "browser\ndocs\nlib\n_build\n"
},
{
"path": ".eslintrc.yml",
"chars": 800,
"preview": "root: true\nparser: '@babel/eslint-parser'\nparserOptions:\n ecmaVersion: 2020\n sourceType: module\n requireConfigFile: f"
},
{
"path": ".gitattributes",
"chars": 46,
"preview": "* text=auto\n*.js text eol=lf\n*.sh text eol=lf\n"
},
{
"path": ".github/workflows/build.yml",
"chars": 1869,
"preview": "name: build\n\non:\n push:\n tags: [v*]\n branches: [master]\n pull_request:\n\npermissions:\n id-token: write # to enab"
},
{
"path": ".gitignore",
"chars": 764,
"preview": "# Logs\nlogs\n*.log\nnpm-debug.log*\n\n# Runtime data\npids\n*.pid\n*.seed\n\n# Directory for instrumented libs generated by jscov"
},
{
"path": ".nvmrc",
"chars": 3,
"preview": "24\n"
},
{
"path": ".prettierrc.json",
"chars": 383,
"preview": "{\n \"tabWidth\": 4,\n \"semi\": true,\n \"singleQuote\": true,\n \"trailingComma\": \"none\",\n \"proseWrap\": \"preserve\",\n \"arrow"
},
{
"path": ".releaserc.json",
"chars": 302,
"preview": "{\n \"branches\": [\n \"master\",\n \"next\"\n ],\n \"plugins\": [\n \"@semantic-release/commit-analyzer\",\n \"@semantic-r"
},
{
"path": ".vscode/extensions.json",
"chars": 358,
"preview": "{\n\t// See http://go.microsoft.com/fwlink/?LinkId=827846\n\t// for the documentation about the extensions.json format\n\t\"rec"
},
{
"path": ".vscode/settings.json",
"chars": 316,
"preview": "// Place your settings in this file to overwrite default and user settings.\n{\n \"eslint.enable\": true,\n \"files.eol\": \"\\"
},
{
"path": "CODE_OF_CONDUCT.md",
"chars": 3217,
"preview": "# Contributor Covenant Code of Conduct\n\n## Our Pledge\n\nIn the interest of fostering an open and welcoming environment, w"
},
{
"path": "CONTRIBUTING.md",
"chars": 2394,
"preview": "# Contributing\n\nThank you for taking the time to contribute to elastic-builder! Your work is truly\nappreciated.\n\nPlease "
},
{
"path": "LICENSE",
"chars": 1070,
"preview": "MIT License\n\nCopyright (c) 2017 Suhas Karanth\n\nPermission is hereby granted, free of charge, to any person obtaining a c"
},
{
"path": "README.md",
"chars": 11958,
"preview": "# elastic-builder\n\n[![npm version][version-badge]][package] [![Build Status][build-badge]][build]\n[![Coverage Status][co"
},
{
"path": "deploy-docs.sh",
"chars": 624,
"preview": "#!/bin/bash -xe\n# See http://tldp.org/LDP/abs/html/options.html\n# -x -> Print each command to stdout before executing it"
},
{
"path": "docs/documentation.yml",
"chars": 4433,
"preview": "toc:\n - name: elastic-builder\n file: intro.md\n - RequestBodySearch\n - name: Queries\n description: |\n These"
},
{
"path": "docs/intro.md",
"chars": 1897,
"preview": "https://github.com/sudo-suhas/elastic-builder\n\n`elastic-builder` is a library for easily building elasticsearch request "
},
{
"path": "docs/publish.md",
"chars": 637,
"preview": "# Publish to npm\n\nThis is primarily a reference for how to publish a new version of this package\nto npm. Currently, @sud"
},
{
"path": "jsconfig.json",
"chars": 411,
"preview": "{\n // See https://go.microsoft.com/fwlink/?LinkId=759670\n // for the documentation about the jsconfig.json format\n"
},
{
"path": "package.json",
"chars": 2883,
"preview": "{\n \"name\": \"elastic-builder\",\n \"version\": \"0.0.0-development\",\n \"description\": \"A JavaScript implementation of the el"
},
{
"path": "repl.js",
"chars": 129,
"preview": "'use strict';\n\nconst repl = require('repl');\n\nconst esb = require('./lib');\n\nrepl.start('elastic-builder > ').context.es"
},
{
"path": "roadmap.md",
"chars": 585,
"preview": "# Roadmap\n\n - [x] Setup github pages, add CNAME\n - [x] Improve README\n + [x] Usage\n + [x] Examples\n + [x] Cr"
},
{
"path": "src/README.md",
"chars": 4607,
"preview": "# Source Guide\nAll good open source repositories have an excellent README guide or a website which\nexplains how to _use_"
},
{
"path": "src/_/index.js",
"chars": 2893,
"preview": "'use strict';\n\n/**\n * Checks if value is null or undefined.\n *\n * @param {*} value The value to check.\n * @returns {bool"
},
{
"path": "src/aggregations/bucket-aggregations/adjacency-matrix-aggregation.js",
"chars": 3719,
"preview": "'use strict';\n\nconst {\n Query,\n util: { checkType, setDefault }\n} = require('../../core');\n\nconst BucketAggregatio"
},
{
"path": "src/aggregations/bucket-aggregations/auto-date-histogram-aggregation.js",
"chars": 4833,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst BucketAggregationBase = require('./bucket-aggregation-base');\n\n/**\n "
},
{
"path": "src/aggregations/bucket-aggregations/bucket-aggregation-base.js",
"chars": 1956,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst {\n Aggregation,\n Script,\n util: { checkType }\n} = require('"
},
{
"path": "src/aggregations/bucket-aggregations/children-aggregation.js",
"chars": 2330,
"preview": "'use strict';\n\nconst BucketAggregationBase = require('./bucket-aggregation-base');\n\nconst ES_REF_URL =\n 'https://www."
},
{
"path": "src/aggregations/bucket-aggregations/composite-agg-values-sources/date-histogram-values-source.js",
"chars": 4959,
"preview": "'use strict';\n\nconst _ = require('../../../_');\n\nconst ValuesSourceBase = require('./values-source-base');\n\nconst REF_UR"
},
{
"path": "src/aggregations/bucket-aggregations/composite-agg-values-sources/histogram-values-source.js",
"chars": 1608,
"preview": "'use strict';\n\nconst _ = require('../../../_');\n\nconst ValuesSourceBase = require('./values-source-base');\n\nconst REF_UR"
},
{
"path": "src/aggregations/bucket-aggregations/composite-agg-values-sources/index.js",
"chars": 287,
"preview": "'use strict';\n\nexports.ValuesSourceBase = require('./values-source-base');\n\nexports.TermsValuesSource = require('./terms"
},
{
"path": "src/aggregations/bucket-aggregations/composite-agg-values-sources/terms-values-source.js",
"chars": 1054,
"preview": "'use strict';\n\nconst ValuesSourceBase = require('./values-source-base');\n\nconst REF_URL =\n 'https://www.elastic.co/gu"
},
{
"path": "src/aggregations/bucket-aggregations/composite-agg-values-sources/values-source-base.js",
"chars": 4238,
"preview": "'use strict';\n\nconst _ = require('../../../_');\n\nconst {\n util: { invalidParam, recursiveToJSON }\n} = require('../../"
},
{
"path": "src/aggregations/bucket-aggregations/composite-aggregation.js",
"chars": 4497,
"preview": "'use strict';\n\nconst {\n Aggregation,\n util: { checkType, constructorWrapper }\n} = require('../../core');\n\nconst {\n"
},
{
"path": "src/aggregations/bucket-aggregations/date-histogram-aggregation.js",
"chars": 3864,
"preview": "'use strict';\n\nconst HistogramAggregationBase = require('./histogram-aggregation-base');\n\n/**\n * A multi-bucket aggregat"
},
{
"path": "src/aggregations/bucket-aggregations/date-range-aggregation.js",
"chars": 2076,
"preview": "'use strict';\n\nconst RangeAggregationBase = require('./range-aggregation-base');\n\n/**\n * A range aggregation that is ded"
},
{
"path": "src/aggregations/bucket-aggregations/diversified-sampler-aggregation.js",
"chars": 4316,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst {\n util: { invalidParam },\n consts: { EXECUTION_HINT_SET }\n} ="
},
{
"path": "src/aggregations/bucket-aggregations/filter-aggregation.js",
"chars": 2621,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst {\n Query,\n util: { checkType }\n} = require('../../core');\n\ncon"
},
{
"path": "src/aggregations/bucket-aggregations/filters-aggregation.js",
"chars": 7553,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst {\n Query,\n util: { checkType, setDefault }\n} = require('../../"
},
{
"path": "src/aggregations/bucket-aggregations/geo-distance-aggregation.js",
"chars": 4622,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst {\n GeoPoint,\n util: { checkType, invalidParam },\n consts: {"
},
{
"path": "src/aggregations/bucket-aggregations/geo-hash-grid-aggregation.js",
"chars": 3110,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst BucketAggregationBase = require('./bucket-aggregation-base');\n\nconst"
},
{
"path": "src/aggregations/bucket-aggregations/geo-hex-grid-aggregation.js",
"chars": 3155,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst BucketAggregationBase = require('./bucket-aggregation-base');\n\nconst"
},
{
"path": "src/aggregations/bucket-aggregations/geo-tile-grid-aggregation.js",
"chars": 6818,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst {\n GeoPoint,\n util: { checkType, setDefault }\n} = require('../"
},
{
"path": "src/aggregations/bucket-aggregations/global-aggregation.js",
"chars": 1738,
"preview": "'use strict';\n\nconst BucketAggregationBase = require('./bucket-aggregation-base');\n\nconst ES_REF_URL =\n 'https://www."
},
{
"path": "src/aggregations/bucket-aggregations/histogram-aggregation-base.js",
"chars": 8431,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst {\n util: { invalidParam }\n} = require('../../core');\n\nconst Bucke"
},
{
"path": "src/aggregations/bucket-aggregations/histogram-aggregation.js",
"chars": 1318,
"preview": "'use strict';\n\nconst HistogramAggregationBase = require('./histogram-aggregation-base');\n\n/**\n * A multi-bucket values s"
},
{
"path": "src/aggregations/bucket-aggregations/index.js",
"chars": 2277,
"preview": "'use strict';\n\nexports.BucketAggregationBase = require('./bucket-aggregation-base');\nexports.HistogramAggregationBase = "
},
{
"path": "src/aggregations/bucket-aggregations/ip-range-aggregation.js",
"chars": 1514,
"preview": "'use strict';\n\nconst RangeAggregationBase = require('./range-aggregation-base');\n\nconst ES_REF_URL =\n 'https://www.el"
},
{
"path": "src/aggregations/bucket-aggregations/missing-aggregation.js",
"chars": 1355,
"preview": "'use strict';\n\nconst BucketAggregationBase = require('./bucket-aggregation-base');\n\nconst ES_REF_URL =\n 'https://www."
},
{
"path": "src/aggregations/bucket-aggregations/nested-aggregation.js",
"chars": 1982,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst BucketAggregationBase = require('./bucket-aggregation-base');\n\nconst"
},
{
"path": "src/aggregations/bucket-aggregations/parent-aggregation.js",
"chars": 2450,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst BucketAggregationBase = require('./bucket-aggregation-base');\n\nconst"
},
{
"path": "src/aggregations/bucket-aggregations/range-aggregation-base.js",
"chars": 4937,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst {\n util: { checkType }\n} = require('../../core');\n\nconst BucketAg"
},
{
"path": "src/aggregations/bucket-aggregations/range-aggregation.js",
"chars": 2114,
"preview": "'use strict';\n\nconst RangeAggregationBase = require('./range-aggregation-base');\n\n/**\n * A multi-bucket value source bas"
},
{
"path": "src/aggregations/bucket-aggregations/rare-terms-aggregation.js",
"chars": 4343,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst BucketAggregationBase = require('./bucket-aggregation-base');\n\nconst"
},
{
"path": "src/aggregations/bucket-aggregations/reverse-nested-aggregation.js",
"chars": 2941,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst BucketAggregationBase = require('./bucket-aggregation-base');\n\nconst"
},
{
"path": "src/aggregations/bucket-aggregations/sampler-aggregation.js",
"chars": 2266,
"preview": "'use strict';\n\nconst BucketAggregationBase = require('./bucket-aggregation-base');\n\nconst ES_REF_URL =\n 'https://www."
},
{
"path": "src/aggregations/bucket-aggregations/significant-aggregation-base.js",
"chars": 5192,
"preview": "'use strict';\n\nconst {\n Query,\n Script,\n util: { checkType }\n} = require('../../core');\n\nconst TermsAggregation"
},
{
"path": "src/aggregations/bucket-aggregations/significant-terms-aggregation.js",
"chars": 1433,
"preview": "'use strict';\n\nconst SignificantAggregationBase = require('./significant-aggregation-base');\n\nconst ES_REF_URL =\n 'ht"
},
{
"path": "src/aggregations/bucket-aggregations/significant-text-aggregation.js",
"chars": 3876,
"preview": "'use strict';\n\nconst {\n util: { checkType }\n} = require('../../core');\n\nconst SignificantAggregationBase = require('."
},
{
"path": "src/aggregations/bucket-aggregations/terms-aggregation-base.js",
"chars": 7277,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst {\n util: { invalidParam },\n consts: { EXECUTION_HINT_SET }\n} ="
},
{
"path": "src/aggregations/bucket-aggregations/terms-aggregation.js",
"chars": 6229,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst {\n util: { invalidParam }\n} = require('../../core');\n\nconst Terms"
},
{
"path": "src/aggregations/bucket-aggregations/variable-width-histogram-aggregation.js",
"chars": 1861,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst BucketAggregationBase = require('./bucket-aggregation-base');\n\n/**\n "
},
{
"path": "src/aggregations/index.js",
"chars": 1089,
"preview": "'use strict';\n\n// Not used in favor of explicit exports.\n// IDE seems to handle those better\n\n// const _ = require('loda"
},
{
"path": "src/aggregations/matrix-aggregations/index.js",
"chars": 87,
"preview": "'use strict';\n\nexports.MatrixStatsAggregation = require('./matrix-stats-aggregation');\n"
},
{
"path": "src/aggregations/matrix-aggregations/matrix-stats-aggregation.js",
"chars": 2504,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst {\n Aggregation,\n util: { checkType }\n} = require('../../core')"
},
{
"path": "src/aggregations/metrics-aggregations/avg-aggregation.js",
"chars": 1676,
"preview": "'use strict';\n\nconst MetricsAggregationBase = require('./metrics-aggregation-base');\n\n/**\n * A single-value metrics aggr"
},
{
"path": "src/aggregations/metrics-aggregations/cardinality-aggregation.js",
"chars": 2506,
"preview": "'use strict';\n\nconst MetricsAggregationBase = require('./metrics-aggregation-base');\n\nconst ES_REF_URL =\n 'https://ww"
},
{
"path": "src/aggregations/metrics-aggregations/extended-stats-aggregation.js",
"chars": 2372,
"preview": "'use strict';\n\nconst MetricsAggregationBase = require('./metrics-aggregation-base');\n\n/**\n * A multi-value metrics aggre"
},
{
"path": "src/aggregations/metrics-aggregations/geo-bounds-aggregation.js",
"chars": 1996,
"preview": "'use strict';\n\nconst MetricsAggregationBase = require('./metrics-aggregation-base');\n\nconst ES_REF_URL =\n 'https://ww"
},
{
"path": "src/aggregations/metrics-aggregations/geo-centroid-aggregation.js",
"chars": 1640,
"preview": "'use strict';\n\nconst MetricsAggregationBase = require('./metrics-aggregation-base');\n\nconst ES_REF_URL =\n 'https://ww"
},
{
"path": "src/aggregations/metrics-aggregations/index.js",
"chars": 1097,
"preview": "'use strict';\n\nexports.MetricsAggregationBase = require('./metrics-aggregation-base');\n\nexports.AvgAggregation = require"
},
{
"path": "src/aggregations/metrics-aggregations/max-aggregation.js",
"chars": 1560,
"preview": "'use strict';\n\nconst MetricsAggregationBase = require('./metrics-aggregation-base');\n\n/**\n * A single-value metrics aggr"
},
{
"path": "src/aggregations/metrics-aggregations/metrics-aggregation-base.js",
"chars": 3034,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst {\n Aggregation,\n Script,\n util: { checkType }\n} = require('"
},
{
"path": "src/aggregations/metrics-aggregations/min-aggregation.js",
"chars": 1556,
"preview": "'use strict';\n\nconst MetricsAggregationBase = require('./metrics-aggregation-base');\n\n/**\n * A single-value metrics aggr"
},
{
"path": "src/aggregations/metrics-aggregations/percentile-ranks-aggregation.js",
"chars": 5938,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst {\n util: { checkType }\n} = require('../../core');\n\nconst MetricsA"
},
{
"path": "src/aggregations/metrics-aggregations/percentiles-aggregation.js",
"chars": 5679,
"preview": "'use strict';\n\nconst {\n util: { checkType }\n} = require('../../core');\n\nconst MetricsAggregationBase = require('./met"
},
{
"path": "src/aggregations/metrics-aggregations/scripted-metric-aggregation.js",
"chars": 5823,
"preview": "'use strict';\n\nconst MetricsAggregationBase = require('./metrics-aggregation-base');\n\nconst ES_REF_URL =\n 'https://ww"
},
{
"path": "src/aggregations/metrics-aggregations/stats-aggregation.js",
"chars": 1597,
"preview": "'use strict';\n\nconst MetricsAggregationBase = require('./metrics-aggregation-base');\n\n/**\n * A multi-value metrics aggre"
},
{
"path": "src/aggregations/metrics-aggregations/sum-aggregation.js",
"chars": 2223,
"preview": "'use strict';\n\nconst MetricsAggregationBase = require('./metrics-aggregation-base');\n\n/**\n * A single-value metrics aggr"
},
{
"path": "src/aggregations/metrics-aggregations/top-hits-aggregation.js",
"chars": 9287,
"preview": "'use strict';\n\nconst MetricsAggregationBase = require('./metrics-aggregation-base'),\n {\n Highlight,\n So"
},
{
"path": "src/aggregations/metrics-aggregations/value-count-aggregation.js",
"chars": 1717,
"preview": "'use strict';\n\nconst MetricsAggregationBase = require('./metrics-aggregation-base');\n\nconst ES_REF_URL =\n 'https://ww"
},
{
"path": "src/aggregations/metrics-aggregations/weighted-average-aggregation.js",
"chars": 5829,
"preview": "'use strict';\n\nconst { Script } = require('../../core');\nconst MetricsAggregationBase = require('./metrics-aggregation-b"
},
{
"path": "src/aggregations/pipeline-aggregations/avg-bucket-aggregation.js",
"chars": 1486,
"preview": "'use strict';\n\nconst PipelineAggregationBase = require('./pipeline-aggregation-base');\n\nconst ES_REF_URL =\n 'https://"
},
{
"path": "src/aggregations/pipeline-aggregations/bucket-script-aggregation.js",
"chars": 2287,
"preview": "'use strict';\n\nconst PipelineAggregationBase = require('./pipeline-aggregation-base');\n\nconst ES_REF_URL =\n 'https://"
},
{
"path": "src/aggregations/pipeline-aggregations/bucket-selector-aggregation.js",
"chars": 2929,
"preview": "'use strict';\n\nconst PipelineAggregationBase = require('./pipeline-aggregation-base');\n\nconst ES_REF_URL =\n 'https://"
},
{
"path": "src/aggregations/pipeline-aggregations/bucket-sort-aggregation.js",
"chars": 2363,
"preview": "'use strict';\n\nconst PipelineAggregationBase = require('./pipeline-aggregation-base');\n\nconst ES_REF_URL =\n 'https://"
},
{
"path": "src/aggregations/pipeline-aggregations/cumulative-sum-aggregation.js",
"chars": 1767,
"preview": "'use strict';\n\nconst PipelineAggregationBase = require('./pipeline-aggregation-base');\n\nconst ES_REF_URL =\n 'https://"
},
{
"path": "src/aggregations/pipeline-aggregations/derivative-aggregation.js",
"chars": 2750,
"preview": "'use strict';\n\nconst PipelineAggregationBase = require('./pipeline-aggregation-base');\n\nconst ES_REF_URL =\n 'https://"
},
{
"path": "src/aggregations/pipeline-aggregations/extended-stats-bucket-aggregation.js",
"chars": 1963,
"preview": "'use strict';\n\nconst PipelineAggregationBase = require('./pipeline-aggregation-base');\n\nconst ES_REF_URL =\n 'https://"
},
{
"path": "src/aggregations/pipeline-aggregations/index.js",
"chars": 1214,
"preview": "'use strict';\n\nexports.PipelineAggregationBase = require('./pipeline-aggregation-base');\n\nexports.AvgBucketAggregation ="
},
{
"path": "src/aggregations/pipeline-aggregations/max-bucket-aggregation.js",
"chars": 1720,
"preview": "'use strict';\n\nconst PipelineAggregationBase = require('./pipeline-aggregation-base');\n\nconst ES_REF_URL =\n 'https://"
},
{
"path": "src/aggregations/pipeline-aggregations/min-bucket-aggregation.js",
"chars": 1720,
"preview": "'use strict';\n\nconst PipelineAggregationBase = require('./pipeline-aggregation-base');\n\nconst ES_REF_URL =\n 'https://"
},
{
"path": "src/aggregations/pipeline-aggregations/moving-average-aggregation.js",
"chars": 5808,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst {\n util: { invalidParam },\n consts: { MODEL_SET }\n} = require("
},
{
"path": "src/aggregations/pipeline-aggregations/moving-function-aggregation.js",
"chars": 3906,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst PipelineAggregationBase = require('./pipeline-aggregation-base');\n\nc"
},
{
"path": "src/aggregations/pipeline-aggregations/percentiles-bucket-aggregation.js",
"chars": 2060,
"preview": "'use strict';\n\nconst {\n util: { checkType }\n} = require('../../core');\n\nconst PipelineAggregationBase = require('./pi"
},
{
"path": "src/aggregations/pipeline-aggregations/pipeline-aggregation-base.js",
"chars": 3621,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst {\n Aggregation,\n util: { invalidParam }\n} = require('../../cor"
},
{
"path": "src/aggregations/pipeline-aggregations/serial-differencing-aggregation.js",
"chars": 1884,
"preview": "'use strict';\n\nconst PipelineAggregationBase = require('./pipeline-aggregation-base');\n\nconst ES_REF_URL =\n 'https://"
},
{
"path": "src/aggregations/pipeline-aggregations/stats-bucket-aggregation.js",
"chars": 1564,
"preview": "'use strict';\n\nconst PipelineAggregationBase = require('./pipeline-aggregation-base');\n\nconst ES_REF_URL =\n 'https://"
},
{
"path": "src/aggregations/pipeline-aggregations/sum-bucket-aggregation.js",
"chars": 1554,
"preview": "'use strict';\n\nconst PipelineAggregationBase = require('./pipeline-aggregation-base');\n\nconst ES_REF_URL =\n 'https://"
},
{
"path": "src/core/aggregation.js",
"chars": 4966,
"preview": "'use strict';\n\nconst _ = require('../_');\n\nconst { checkType, recursiveToJSON } = require('./util');\n\n/**\n * Base class "
},
{
"path": "src/core/consts.js",
"chars": 2299,
"preview": "'use strict';\n\n// Used in Fiversified Sampler aggrenation\nexports.EXECUTION_HINT_SET = new Set([\n 'map',\n 'global_"
},
{
"path": "src/core/geo-point.js",
"chars": 3808,
"preview": "'use strict';\n\nconst _ = require('../_');\n\nconst { checkType } = require('./util');\n\n/**\n * A `GeoPoint` object that can"
},
{
"path": "src/core/geo-shape.js",
"chars": 3949,
"preview": "'use strict';\n\nconst _ = require('../_');\n\nconst { checkType, invalidParam } = require('./util');\nconst { GEO_SHAPE_TYPE"
},
{
"path": "src/core/highlight.js",
"chars": 18470,
"preview": "'use strict';\n\nconst _ = require('../_');\nconst Query = require('./query');\nconst { checkType, invalidParam, recursiveTo"
},
{
"path": "src/core/index.js",
"chars": 786,
"preview": "'use strict';\n\n// Base classes\n\nexports.RequestBodySearch = require('./request-body-search');\n\nexports.Aggregation = req"
},
{
"path": "src/core/indexed-shape.js",
"chars": 2553,
"preview": "'use strict';\n\nconst _ = require('../_');\n\n/**\n * A shape which has already been indexed in another index and/or index\n "
},
{
"path": "src/core/inner-hits.js",
"chars": 7316,
"preview": "'use strict';\n\nconst _ = require('../_');\n\nconst Sort = require('./sort');\nconst Highlight = require('./highlight');\n\nco"
},
{
"path": "src/core/inspect.js",
"chars": 10428,
"preview": "/* istanbul ignore file */\n/* eslint-disable max-lines */\n'use strict';\n\nconst _ = require('../_');\n\n/**\n * Echos the va"
},
{
"path": "src/core/knn.js",
"chars": 5109,
"preview": "'use strict';\n\nconst { recursiveToJSON, checkType } = require('./util');\nconst Query = require('./query');\n\n/**\n * Class"
},
{
"path": "src/core/query.js",
"chars": 1969,
"preview": "'use strict';\n\nconst { recursiveToJSON } = require('./util');\n\n/**\n * Base class implementation for all query types.\n *\n"
},
{
"path": "src/core/request-body-search.js",
"chars": 30661,
"preview": "'use strict';\n\nconst _ = require('../_');\n\nconst Query = require('./query'),\n Aggregation = require('./aggregation'),"
},
{
"path": "src/core/rescore.js",
"chars": 4235,
"preview": "'use strict';\n\nconst _ = require('../_');\n\nconst Query = require('./query');\nconst { checkType, invalidParam, recursiveT"
},
{
"path": "src/core/runtime-field.js",
"chars": 3426,
"preview": "'use strict';\n\nconst _ = require('../_');\nconst validType = [\n 'boolean',\n 'composite',\n 'date',\n 'double',\n"
},
{
"path": "src/core/script.js",
"chars": 7487,
"preview": "'use strict';\n\nconst _ = require('../_');\n\n/**\n * Class supporting the Elasticsearch scripting API.\n *\n * [Elasticsearch"
},
{
"path": "src/core/search-template.js",
"chars": 5781,
"preview": "'use strict';\n\nconst _ = require('../_');\n\nconst { recursiveToJSON } = require('./util');\n\n/**\n * Class supporting the E"
},
{
"path": "src/core/sort.js",
"chars": 12753,
"preview": "'use strict';\n\nconst _ = require('../_');\n\nconst Query = require('./query');\nconst Script = require('./script');\nconst {"
},
{
"path": "src/core/suggester.js",
"chars": 2230,
"preview": "'use strict';\n\nconst _ = require('../_');\n\n/**\n * Base class implementation for all suggester types.\n *\n * **NOTE:** Ins"
},
{
"path": "src/core/util.js",
"chars": 4118,
"preview": "'use strict';\n\nconst _ = require('../_');\n\nconst inspect = require('./inspect');\n\n/**\n * Check if the object is instance"
},
{
"path": "src/index.d.ts",
"chars": 402328,
"preview": "// Type definitions for elastic-builder\n// Project: https://elastic-builder.js.org\n// Definitions by: Suhas Karanth <sud"
},
{
"path": "src/index.js",
"chars": 22553,
"preview": "/* eslint-disable max-lines */\n\n'use strict';\n\nconst {\n RequestBodySearch,\n Highlight,\n Script,\n GeoPoint,\n "
},
{
"path": "src/queries/compound-queries/bool-query.js",
"chars": 7684,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst {\n Query,\n util: { checkType, setDefault, recursiveToJSON }\n} "
},
{
"path": "src/queries/compound-queries/boosting-query.js",
"chars": 2386,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst {\n Query,\n util: { checkType }\n} = require('../../core');\n\n/**"
},
{
"path": "src/queries/compound-queries/constant-score-query.js",
"chars": 1770,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst {\n Query,\n util: { checkType }\n} = require('../../core');\n\n/**"
},
{
"path": "src/queries/compound-queries/dis-max-query.js",
"chars": 2394,
"preview": "'use strict';\n\nconst {\n Query,\n util: { checkType, setDefault }\n} = require('../../core');\n\n/**\n * A query that ge"
},
{
"path": "src/queries/compound-queries/function-score-query.js",
"chars": 5255,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst {\n Query,\n util: { checkType, invalidParam },\n consts: { SC"
},
{
"path": "src/queries/compound-queries/index.js",
"chars": 450,
"preview": "'use strict';\n\nexports.scoreFunctions = require('./score-functions');\n\nexports.ConstantScoreQuery = require('./constant-"
},
{
"path": "src/queries/compound-queries/score-functions/decay-score-function.js",
"chars": 6044,
"preview": "'use strict';\n\nconst _ = require('../../../_');\n\nconst {\n util: { invalidParam, recursiveToJSON }\n} = require('../../"
},
{
"path": "src/queries/compound-queries/score-functions/field-value-factor-function.js",
"chars": 3372,
"preview": "'use strict';\n\nconst _ = require('../../../_');\n\nconst {\n util: { invalidParam },\n consts: { FIELD_MODIFIER_SET }\n"
},
{
"path": "src/queries/compound-queries/score-functions/index.js",
"chars": 407,
"preview": "'use strict';\n\nexports.ScoreFunction = require('./score-function');\nexports.ScriptScoreFunction = require('./script-scor"
},
{
"path": "src/queries/compound-queries/score-functions/random-score-function.js",
"chars": 941,
"preview": "'use strict';\n\nconst ScoreFunction = require('./score-function');\n\n/**\n * The `random_score` generates scores using a ha"
},
{
"path": "src/queries/compound-queries/score-functions/score-function.js",
"chars": 1915,
"preview": "'use strict';\n\nconst {\n Query,\n util: { checkType, recursiveToJSON }\n} = require('../../../core');\n\n/**\n * `ScoreF"
},
{
"path": "src/queries/compound-queries/score-functions/script-score-function.js",
"chars": 1518,
"preview": "'use strict';\n\nconst _ = require('../../../_');\n\nconst ScoreFunction = require('./score-function');\n\n/**\n * The `script_"
},
{
"path": "src/queries/compound-queries/score-functions/weight-score-function.js",
"chars": 1562,
"preview": "'use strict';\n\nconst _ = require('../../../_');\n\nconst ScoreFunction = require('./score-function');\n\nconst {\n util: {"
},
{
"path": "src/queries/full-text-queries/combined-fields-query.js",
"chars": 4909,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst {\n util: { checkType, invalidParam }\n} = require('../../core');\nc"
},
{
"path": "src/queries/full-text-queries/common-terms-query.js",
"chars": 6721,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst {\n util: { invalidParam, setDefault }\n} = require('../../core');\n"
},
{
"path": "src/queries/full-text-queries/full-text-query-base.js",
"chars": 2936,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst { Query } = require('../../core');\n\n/**\n * The `FullTextQueryBase` p"
},
{
"path": "src/queries/full-text-queries/index.js",
"chars": 779,
"preview": "'use strict';\n\nexports.FullTextQueryBase = require('./full-text-query-base');\nexports.MatchPhraseQueryBase = require('./"
},
{
"path": "src/queries/full-text-queries/match-phrase-prefix-query.js",
"chars": 1311,
"preview": "'use strict';\n\nconst MatchPhraseQueryBase = require('./match-phrase-query-base');\n\nconst ES_REF_URL =\n 'https://www.e"
},
{
"path": "src/queries/full-text-queries/match-phrase-query-base.js",
"chars": 1572,
"preview": "'use strict';\n\nconst MonoFieldQueryBase = require('./mono-field-query-base');\n\n/**\n * The `MatchPhraseQueryBase` provide"
},
{
"path": "src/queries/full-text-queries/match-phrase-query.js",
"chars": 931,
"preview": "'use strict';\n\nconst MatchPhraseQueryBase = require('./match-phrase-query-base');\n\nconst ES_REF_URL =\n 'https://www.e"
},
{
"path": "src/queries/full-text-queries/match-query.js",
"chars": 9541,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst {\n util: { invalidParam }\n} = require('../../core');\nconst MonoFi"
},
{
"path": "src/queries/full-text-queries/mono-field-query-base.js",
"chars": 1949,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst FullTextQueryBase = require('./full-text-query-base');\n\n/**\n * The `"
},
{
"path": "src/queries/full-text-queries/multi-match-query.js",
"chars": 14195,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst {\n util: { checkType, invalidParam },\n consts: { MULTI_MATCH_T"
},
{
"path": "src/queries/full-text-queries/query-string-query-base.js",
"chars": 5570,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst {\n util: { checkType, setDefault, invalidParam }\n} = require('../"
},
{
"path": "src/queries/full-text-queries/query-string-query.js",
"chars": 10831,
"preview": "'use strict';\n\nconst QueryStringQueryBase = require('./query-string-query-base');\nconst { validateRewiteMethod } = requi"
},
{
"path": "src/queries/full-text-queries/simple-query-string-query.js",
"chars": 1816,
"preview": "'use strict';\n\nconst QueryStringQueryBase = require('./query-string-query-base');\n\nconst ES_REF_URL =\n 'https://www.e"
},
{
"path": "src/queries/geo-queries/geo-bounding-box-query.js",
"chars": 5373,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst {\n GeoPoint,\n util: { checkType, invalidParam }\n} = require('."
},
{
"path": "src/queries/geo-queries/geo-distance-query.js",
"chars": 2991,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst {\n GeoPoint,\n util: { checkType, invalidParam }\n} = require('."
},
{
"path": "src/queries/geo-queries/geo-polygon-query.js",
"chars": 1923,
"preview": "'use strict';\n\nconst {\n util: { checkType }\n} = require('../../core');\n\nconst GeoQueryBase = require('./geo-query-bas"
},
{
"path": "src/queries/geo-queries/geo-query-base.js",
"chars": 2774,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst {\n Query,\n util: { invalidParam, recursiveToJSON }\n} = require"
},
{
"path": "src/queries/geo-queries/geo-shape-query.js",
"chars": 4090,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst {\n GeoShape,\n IndexedShape,\n util: { checkType, invalidPara"
},
{
"path": "src/queries/geo-queries/index.js",
"chars": 307,
"preview": "'use strict';\n\nexports.GeoQueryBase = require('./geo-query-base');\n\nexports.GeoShapeQuery = require('./geo-shape-query')"
},
{
"path": "src/queries/helper.js",
"chars": 1039,
"preview": "'use strict';\n\nconst { inspect } = require('../core/inspect');\n\nconst {\n util: { firstDigitPos },\n consts: { REWRI"
},
{
"path": "src/queries/index.js",
"chars": 575,
"preview": "'use strict';\n\nexports.MatchAllQuery = require('./match-all-query');\nexports.MatchNoneQuery = require('./match-none-quer"
},
{
"path": "src/queries/joining-queries/has-child-query.js",
"chars": 3208,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst JoiningQueryBase = require('./joining-query-base');\n\nconst ES_REF_UR"
},
{
"path": "src/queries/joining-queries/has-parent-query.js",
"chars": 3135,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst JoiningQueryBase = require('./joining-query-base');\n\nconst ES_REF_UR"
},
{
"path": "src/queries/joining-queries/index.js",
"chars": 289,
"preview": "'use strict';\n\nexports.JoiningQueryBase = require('./joining-query-base');\n\nexports.NestedQuery = require('./nested-quer"
},
{
"path": "src/queries/joining-queries/joining-query-base.js",
"chars": 3251,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst {\n Query,\n InnerHits,\n util: { checkType, invalidParam },\n "
},
{
"path": "src/queries/joining-queries/nested-query.js",
"chars": 1513,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst JoiningQueryBase = require('./joining-query-base');\n\nconst ES_REF_UR"
},
{
"path": "src/queries/joining-queries/parent-id-query.js",
"chars": 1950,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst { Query } = require('../../core');\n\n/**\n * The `parent_id` query can"
},
{
"path": "src/queries/match-all-query.js",
"chars": 536,
"preview": "'use strict';\n\nconst { Query } = require('../core');\n\n/**\n * The most simple query, which matches all documents, giving "
},
{
"path": "src/queries/match-none-query.js",
"chars": 506,
"preview": "'use strict';\n\nconst { Query } = require('../core');\n\n/**\n * The inverse of the `match_all` query, which matches no docu"
},
{
"path": "src/queries/span-queries/index.js",
"chars": 616,
"preview": "'use strict';\n\nexports.SpanLittleBigQueryBase = require('./span-little-big-query-base');\n\nexports.SpanTermQuery = requir"
},
{
"path": "src/queries/span-queries/span-containing-query.js",
"chars": 998,
"preview": "'use strict';\n\nconst SpanLittleBigQueryBase = require('./span-little-big-query-base');\n\n/**\n * Returns matches which enc"
},
{
"path": "src/queries/span-queries/span-field-masking-query.js",
"chars": 2265,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst {\n util: { checkType }\n} = require('../../core');\n\nconst SpanQuer"
},
{
"path": "src/queries/span-queries/span-first-query.js",
"chars": 1517,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst {\n util: { checkType }\n} = require('../../core');\n\nconst SpanQuer"
},
{
"path": "src/queries/span-queries/span-little-big-query-base.js",
"chars": 1162,
"preview": "'use strict';\n\nconst {\n util: { checkType }\n} = require('../../core');\n\nconst SpanQueryBase = require('./span-query-b"
},
{
"path": "src/queries/span-queries/span-multi-term-query.js",
"chars": 1440,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst {\n util: { checkType }\n} = require('../../core');\n\nconst { MultiT"
},
{
"path": "src/queries/span-queries/span-near-query.js",
"chars": 2200,
"preview": "'use strict';\n\nconst {\n util: { checkType }\n} = require('../../core');\n\nconst SpanQueryBase = require('./span-query-b"
},
{
"path": "src/queries/span-queries/span-not-query.js",
"chars": 2639,
"preview": "'use strict';\n\nconst {\n util: { checkType }\n} = require('../../core');\n\nconst SpanQueryBase = require('./span-query-b"
},
{
"path": "src/queries/span-queries/span-or-query.js",
"chars": 1365,
"preview": "'use strict';\n\nconst {\n util: { checkType }\n} = require('../../core');\n\nconst SpanQueryBase = require('./span-query-b"
},
{
"path": "src/queries/span-queries/span-query-base.js",
"chars": 425,
"preview": "'use strict';\n\nconst { Query } = require('../../core');\n\n/**\n * Interface-like class used to group and identify various "
},
{
"path": "src/queries/span-queries/span-term-query.js",
"chars": 2309,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst SpanQueryBase = require('./span-query-base');\n\n/**\n * Matches spans "
},
{
"path": "src/queries/span-queries/span-within-query.js",
"chars": 990,
"preview": "'use strict';\n\nconst SpanLittleBigQueryBase = require('./span-little-big-query-base');\n\n/**\n * Returns matches which are"
},
{
"path": "src/queries/specialized-queries/distance-feature-query.js",
"chars": 2437,
"preview": "'use strict';\n\nconst _ = require('../../_');\nconst { Query } = require('../../core');\n\n/**\n * The `distance_feature` que"
},
{
"path": "src/queries/specialized-queries/index.js",
"chars": 370,
"preview": "'use strict';\n\nexports.MoreLikeThisQuery = require('./more-like-this-query');\nexports.ScriptQuery = require('./script-qu"
},
{
"path": "src/queries/specialized-queries/more-like-this-query.js",
"chars": 11517,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst {\n Query,\n util: { checkType }\n} = require('../../core');\n\n/**"
},
{
"path": "src/queries/specialized-queries/percolate-query.js",
"chars": 5837,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst {\n util: { checkType },\n Query\n} = require('../../core');\n\n/**"
},
{
"path": "src/queries/specialized-queries/rank-feature-query.js",
"chars": 2911,
"preview": "'use strict';\n\nconst { Query } = require('../../core');\nconst _ = require('../../_');\n\n/**\n * The rank_feature query boo"
},
{
"path": "src/queries/specialized-queries/script-query.js",
"chars": 1127,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst {\n Query,\n Script,\n util: { checkType }\n} = require('../../"
},
{
"path": "src/queries/specialized-queries/script-score-query.js",
"chars": 1767,
"preview": "'use strict';\n\nconst {\n Query,\n Script,\n util: { checkType }\n} = require('../../core');\n\n/**\n * A query that us"
},
{
"path": "src/queries/term-level-queries/exists-query.js",
"chars": 968,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst { Query } = require('../../core');\n\n/**\n * Returns documents that ha"
},
{
"path": "src/queries/term-level-queries/fuzzy-query.js",
"chars": 2826,
"preview": "'use strict';\n\nconst MultiTermQueryBase = require('./multi-term-query-base');\n\n/**\n * The fuzzy query generates all poss"
},
{
"path": "src/queries/term-level-queries/ids-query.js",
"chars": 1840,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst {\n Query,\n util: { checkType }\n} = require('../../core');\n\n/**"
},
{
"path": "src/queries/term-level-queries/index.js",
"chars": 609,
"preview": "'use strict';\n\nexports.MultiTermQueryBase = require('./multi-term-query-base');\n\nexports.TermQuery = require('./term-que"
},
{
"path": "src/queries/term-level-queries/multi-term-query-base.js",
"chars": 585,
"preview": "'use strict';\n\nconst ValueTermQueryBase = require('./value-term-query-base');\n\n/**\n * Interface-like class used to group"
},
{
"path": "src/queries/term-level-queries/prefix-query.js",
"chars": 2602,
"preview": "'use strict';\n\nconst MultiTermQueryBase = require('./multi-term-query-base');\nconst { validateRewiteMethod } = require('"
},
{
"path": "src/queries/term-level-queries/range-query.js",
"chars": 5521,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst {\n util: { invalidParam },\n consts: { GEO_RELATION_SET }\n} = r"
},
{
"path": "src/queries/term-level-queries/regexp-query.js",
"chars": 4400,
"preview": "'use strict';\n\nconst MultiTermQueryBase = require('./multi-term-query-base');\nconst { validateRewiteMethod } = require('"
},
{
"path": "src/queries/term-level-queries/term-query.js",
"chars": 689,
"preview": "'use strict';\n\nconst ValueTermQueryBase = require('./value-term-query-base');\n\n/**\n * The `term` query finds documents t"
},
{
"path": "src/queries/term-level-queries/terms-query.js",
"chars": 5437,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst {\n util: { checkType }\n} = require('../../core');\n\nconst { Query "
},
{
"path": "src/queries/term-level-queries/terms-set-query.js",
"chars": 3694,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst {\n Query,\n util: { checkType }\n} = require('../../core');\n\n/**"
},
{
"path": "src/queries/term-level-queries/type-query.js",
"chars": 1220,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst { Query } = require('../../core');\n\n/**\n * Filters documents matchin"
},
{
"path": "src/queries/term-level-queries/value-term-query-base.js",
"chars": 2393,
"preview": "'use strict';\n\nconst _ = require('../../_');\n\nconst { Query } = require('../../core');\n\n/**\n * The `ValueTermQueryBase` "
},
{
"path": "src/queries/term-level-queries/wildcard-query.js",
"chars": 3068,
"preview": "'use strict';\n\nconst MultiTermQueryBase = require('./multi-term-query-base');\nconst { validateRewiteMethod } = require('"
},
{
"path": "src/queries/vector-queries/index.js",
"chars": 130,
"preview": "'use strict';\n\nexports.SparseVectorQuery = require('./sparse-vector-query');\nexports.SemanticQuery = require('./semantic"
},
{
"path": "src/queries/vector-queries/semantic-query.js",
"chars": 1480,
"preview": "'use strict';\n\nconst { Query } = require('../../core');\nconst _ = require('../../_');\n\n/**\n * The semantic query enables"
},
{
"path": "src/queries/vector-queries/sparse-vector-query.js",
"chars": 3840,
"preview": "'use strict';\n\nconst { Query } = require('../../core');\nconst _ = require('../../_');\n\n/**\n * The sparse vector query ex"
},
{
"path": "src/recipes.js",
"chars": 3573,
"preview": "'use strict';\n\nconst _ = require('./_');\n\nconst {\n MatchAllQuery,\n termLevelQueries: { ExistsQuery },\n compound"
},
{
"path": "src/suggesters/analyzed-suggester-base.js",
"chars": 2711,
"preview": "'use strict';\n\nconst _ = require('../_');\n\nconst { Suggester } = require('../core');\n\n/**\n * The `AnalyzedSuggesterBase`"
}
]
// ... and 167 more files (download for full content)
About this extraction
This page contains the full source code of the sudo-suhas/elastic-builder GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 367 files (1.6 MB), approximately 389.9k tokens, and a symbol index with 1272 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.