Comments (3)
Big 👍 for custom aggregations. The syntax there is less predictable and prior to creating #64, that was the feature I was looking for.
With filters & queries: My feeling is that the syntax there is very predictable, so I'd generally expect a .filter(<type>, <field>, <value>)
API. The <type>
can even be generically converted from camelCase and kebab-case to snake_case. (lodash has some convenience functions around that)
from bodybuilder.
Starting to look at what it would take to put together a generic api for queries/filters, I started collecting notes trying to categorize all the different forms a query clause can take.
Query/Filter structures I've observed:
No field (Match All query):
{
<type>: {}
}
// example:
{
match_all: {}
}
Field but no value:
{
<type>: {
field: <field>
}
}
// or
{
<type>: {
value: <field>
}
}
// examples:
{
exists: {
field: 'some_field_name'
}
}
{
type: {
value: 'some_type_name'
}
}
Field with value:
{
<type>: {
<field>: <value>
}
}
// examples:
{
term: {
user: 'kimchy'
}
}
{
terms: {
user: ['kimchy', 'rob']
}
}
Field with value and more options:
{
<type>: {
<field>: <value>,
<a>: <b>,
<c>: <d>,
...
}
}
// example:
{
geo_distance: {
distance: '12km',
point: {
lat: 40,
lon: 20
}
}
}
Join queries such as nested query:
{
<type>: {
path: <parent_field>,
query: {
<type>: {
'<parent_field>.<child_field>': <value>
}
}
}
}
// examples:
{
nested: {
path: 'obj1',
query: {
match: {
'obj1.color': 'blue'
}
}
}
}
{
has_child: {
type: 'blog_tag',
query: {
term: {
tag: 'something'
}
}
}
}
// perhaps these can be treated as a special case of nested queries?
from bodybuilder.
bodybuilder 2 is in beta! https://github.com/danpaz/bodybuilder/releases/tag/v2.0.0-beta.1
from bodybuilder.
Related Issues (20)
- Script Based Sort HOT 1
- Can you please publish 2.2.22 to NPM? HOT 3
- Problem with 2.2.23 npm release? HOT 14
- Bodybuilder v3.0 HOT 8
- Escaping hyphens HOT 3
- Lodash & treeshaking. HOT 2
- Travis no longer builds on travis-ci.org HOT 1
- [Question] Is there a way to convert ES queries to bodybuilder implementation? HOT 3
- [Question] How to merge two bodybuilder queries? HOT 3
- How to convert the query to bodybuilder syntax? HOT 1
- Use npm automation token in CI
- Support for aggregations without field missing HOT 1
- Elasticsearch msearch? HOT 1
- Is it possible to control the order of methods when chaining multiple? HOT 2
- Release new version from master branch HOT 1
- Dependency lodash.set has Prototype Pollution vulnerability HOT 6
- [Question] How would you use Bodybuiler on aggs queries? HOT 2
- How to generate the following nested statements HOT 1
- Embed types into the source code
- Embed types into the source code HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bodybuilder.