Skip to content

Instantly share code, notes, and snippets.

@timglabisch
Created September 3, 2014 20:30
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 timglabisch/b0b486c700355361e683 to your computer and use it in GitHub Desktop.
Save timglabisch/b0b486c700355361e683 to your computer and use it in GitHub Desktop.
GET /tests/_search
{
"query": {
"match_all": {}
},
"aggs": {
"all": {
"global": {},
"aggs": {
"top_hits": {
"size": 1
}
}
}
}
}
POST /tests/_search
{
"size": 1,
"from": 2,
"query": {
"filtered": {
"filter": {
"term": {
"_id": 2
}
}
}
},
"aggs": {
"hits": {
"top_hits": {
"size": 1,
"from": 0
},
"aggs": {
"min_price_variant": {
"nested": {
"path": "variants"
},
"aggs": {
"ttt": {
"terms": {
"field": "variants.stock"
}
}
}
}
}
}
}
}
GET /tests/_search
{
"query": {
"function_score": {
"score_mode": "first",
"boost_mode": "replace",
"functions": [
{
"script_score": {
"script": "def score=0;for(term in terms){ score += term }; return score",
"lang": "groovy"
}
}
]
}
}
}
GET /tests/_search
{
"query": {
"function_score": {
"score_mode": "first",
"boost_mode": "replace",
"functions": [
{
"linear": {
"foo": {
"origin": 1,
"scale": 3
}
}
}
]
}
}
}
DELETE tests
PUT /tests/
{
"mappings": {
"example": {
"properties": {
"stock": {
"type": "long"
},
"variants": {
"type": "nested",
"properties": {
"stock" : {
"type": "long"
}
}
}
}
}
}
}
PUT /tests/example/4
{
"foo": 3
}
POST /tests/example/2
{
"price": 2,
"date": "20140814T154513Z",
"variants": [
{
"stock": 7
}
]
}
POST /tests/example/3
{
"price": 3,
"date": "20140719T154513Z",
"variants": [
{
"stock": 9
},
{
"stock": 99
}
]
}
POST /tests/example/4
{
"price": 4,
"date": "20140619T154513Z",
"variants": [
{
"stock": 2
}
]
}
DELETE /testp
POST /testp/
{
"mappings": {
"variant": {
"_parent": {
"type": "product"
}
},
"product": {
"properties": {
"sku": {
"type": "string"
},
"type": {
"type": "string"
}
}
}
}
}
POST /testp/product/2
{
"_id": "2",
"type": "product"
}
POST /testp/variant/foo?parent=2
{
"_parent": "2",
"type": "variant"
}
POST /_search
{
"query": { "match_all": {}}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment