Skip to content

Instantly share code, notes, and snippets.

@cheyner
Last active August 29, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cheyner/10471361 to your computer and use it in GitHub Desktop.
Save cheyner/10471361 to your computer and use it in GitHub Desktop.
Parametric search examples: Aggregating
Array
(
[size] => 10
[from] => 0
[index] => 23-parts
[type] => part
[body] => Array
(
[query] => Array
(
[filtered] => Array
(
[filter] => Array
(
[and] => Array
(
[0] => Array
(
[term] => Array
(
[user_id] => 23
)
)
[1] => Array
(
[prefix] => Array
(
[category.nodepath] => Ferrite Cores>>Toroids
)
)
[2] => Array
(
[nested] => Array
(
[path] => attributes
[filter] => Array
(
[term] => Array
(
[attributes.name] => weight_gm
)
)
)
)
)
)
[query] => Array
(
)
)
)
[aggregations] => Array
(
[manufacturers] => Array
(
[terms] => Array
(
[field] => manufacturer
)
)
[in_stock_only] => Array
(
[filter] => Array
(
[range] => Array
(
[quantity] => Array
(
[gt] => 0
)
)
)
)
[attributes] => Array
(
[nested] => Array
(
[path] => attributes
)
[aggs] => Array
(
[freqrange] => Array
(
[filter] => Array
(
[term] => Array
(
[attributes.name] => freqrange
)
)
[aggs] => Array
(
[options] => Array
(
[terms] => Array
(
[field] => attributes.value
[order] => Array
(
[_term] => asc
)
)
)
)
)
[weight_gm] => Array
(
[filter] => Array
(
[term] => Array
(
[attributes.name] => weight_gm
)
)
[aggs] => Array
(
[options] => Array
(
[terms] => Array
(
[field] => attributes.value
[order] => Array
(
[_term] => asc
)
)
)
)
)
)
)
)
[filter] => Array
(
[and] => Array
(
[0] => Array
(
[nested] => Array
(
[path] => attributes
[filter] => Array
(
[bool] => Array
(
[must] => Array
(
[0] => Array
(
[term] => Array
(
[attributes.name] => weight_gm
)
)
[1] => Array
(
[terms] => Array
(
[attributes.value] => Array
(
[0] => 0.14
)
)
)
)
)
)
)
)
)
)
)
);
Array
(
[size] => 100
[from] => 0
[index] => parts
[type] => part
[body] => Array
(
[query] => Array
(
[filtered] => Array
(
[filter] => Array
(
[and] => Array
(
[0] => Array
(
[term] => Array
(
[user_id] => 23
)
)
[1] => Array
(
[nested] => Array
(
[path] => attributes
[filter] => Array
(
[bool] => Array
(
[must] => Array
(
[0] => Array
(
[term] => Array
(
[attributes.name] => weight_gm
)
)
[1] => Array
(
[terms] => Array
(
[attributes.value] => Array
(
[0] => 0.14
)
)
)
)
)
)
)
)
[2] => Array
(
[prefix] => Array
(
[category.nodepath] => Ferrite Cores>>Toroids
)
)
)
)
[query] => Array
(
)
)
)
[aggregations] => Array
(
[in_stock_only] => Array
(
[filter] => Array
(
[range] => Array
(
[quantity] => Array
(
[gt] => 0
)
)
)
)
[manufacturer] => Array
(
[terms] => Array
(
[field] => manufacturer
)
)
[category] => Array
(
[terms] => Array
(
[field] => category.nodepath
)
)
[attributes] => Array
(
[nested] => Array
(
[path] => attributes
)
[aggs] => Array
(
[name] => Array
(
[terms] => Array
(
[field] => attributes.name
)
[aggs] => Array
(
[options] => Array
(
[terms] => Array
(
[field] => attributes.value
)
)
)
)
)
)
)
)
);
<?php
$settings['body']['aggregations']['in_stock_only'] = array(
'filter' => array(
'nested' => array(
'path' => 'attributes',
'filter' => array(
'bool' => array(
'must' => array(
array(
'range' => array(
'quantity' => array(
'gt' => 0
)
)
),
array(
'term' => array(
'attributes.name' => 'weight_gm'
)
),
array(
'term' => array(
'attributes.value' => '0.14'
)
)
)
)
)
)
)
);?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment