Skip to content

Instantly share code, notes, and snippets.

View xethorn's full-sized avatar
👨‍💻
I may be slow to respond.

Michael Ortali xethorn

👨‍💻
I may be slow to respond.
View GitHub Profile
@xethorn
xethorn / elasticsearch_min_max_children_with_nested_datatypes.md
Last active April 28, 2021 02:02
Elasticsearch: min_children and max_children with nested datatypes for Elastic 6 and 7+.

Elasticsearch: Min and Max Children Query with Nested Datatypes

Elasticsearch does not support min_children and max_children for nested datatypes by default (see: issue #10043). In case you need this behavior, this gist provides an alternative solution. Please note that I haven't benchmarked it against join queries.

Alternative solution

To support min_children and max_children for your nested query, all you have to do is to use a function_score query. To make this more concrete: you have an index called Person with the following mapping:

  • first_name (text)
  • email (text)
from datetime import datetime
from datetime import timezone
def now_utc_timestamp():
"""Create a utc timestamp.
Args:
timestamp (int): the current timestamp, optional.
@xethorn
xethorn / url.externs.js
Last active August 29, 2015 14:19
Extern url
/**
* @param {...*} var_args
* @return {*}
*/
var url = function(var_args) {};
@xethorn
xethorn / gist:2cefcc85d5093b12d065
Last active August 29, 2015 14:16
Garcon - Country flow
import boto.swf.layer2 as swf
from garcon import activity
from garcon import runner
from garcon import task
import random
domain = 'dev'
name = 'country_flow'
@xethorn
xethorn / flow.py
Last active August 29, 2015 14:16
Garcon - Context Example
import boto.swf.layer2 as swf
from garcon import activity
from garcon import runner
from garcon import task
domain = 'dev'
name = 'context_example'
create = activity.create(domain, name)
@xethorn
xethorn / gist:74912ba007c0b7f75667
Last active August 29, 2015 14:16
Garcon - Retry example
test_activity_3 = create(
name='activity_3',
retry=10,
requires=[test_activity_1],
run=runner.Sync(activity_failure))
@xethorn
xethorn / README.md
Created February 24, 2015 19:07
Garcon - Original Boto Example
@xethorn
xethorn / gist:f0799617bab540e70227
Last active September 11, 2015 21:59
Garcon - Boto Example
from garcon import activity
from garcon import runner
domain = 'dev'
name = 'boto_tutorial'
create = activity.create(domain, name)
a_tasks = create(
name='a_tasks',
@xethorn
xethorn / index.js
Last active January 11, 2024 06:05
Automated inclusion of services
/**
* Automated inclusion of services with Fluxible
*
* The services are used on the server side as a resource. They fetch
* an endpoint and return the data. Right now for each resource, you
* need to manually include the file.
*
* The code sample needs to be placed in the /services/ directory of
* your application - and be named index.js. To register all your
* services, all you have to do: