Skip to content

Instantly share code, notes, and snippets.

@oguzhaneren
Last active April 11, 2019 08:08
Show Gist options
  • Save oguzhaneren/c27f334617fcf53c21a4c60df193100a to your computer and use it in GitHub Desktop.
Save oguzhaneren/c27f334617fcf53c21a4c60df193100a to your computer and use it in GitHub Desktop.
Elastic queries
GET campaignproductcontent/_search
{
"query": {
"bool": {
"filter": [
{
"term": {
"campaignId": "301997"
}
},
{
"term": {
"listings.isTransferred": true
}
}
]
}
}
}
GET product/_search
{
"_source": false,
"aggs": {
"brand": {
"terms": {
"field": "brand.id"
},
"aggs": {
"names": {
"top_hits": {
"size": 1,
"_source": [
"brand.name"
]
}
}
}
},
"category": {
"terms": {
"field": "category.id",
"size": 10000
},
"aggs": {
"names": {
"top_hits": {
"size": 1,
"_source": [
"category.name"
]
}
}
}
}
},
"query": {
"bool": {
"filter": [
{
"terms": {
"id": [
3288097,
3807932,
4096713,
3288345
],
"boost": 1
}
}
],
"adjust_pure_negative": true,
"boost": 1
}
}
}
GET product/_search
{
"query": {
"bool": {
"filter": {
"script": {
"script": {
"source": "doc['productContents.productVariants.barcode'].values.size() == 1",
"lang": "painless"
}
}
}
}
}
}
GET category-lookup/_search
{
"size": 4,
"_source": ["id","realId","name","displayName","categoryAttributes.attribute.id"
,"categoryAttributes.attribute.name","categoryAttributes.attribute.type","categoryAttributes.attributeValues.id","categoryAttributes.attributeValues.name"],
"query": {
"match_all": {}
},
"sort": {
"_script": {
"type": "number",
"script": {
"lang": "painless",
"source": "doc['categoryAttributes.required'].values.size()"
},
"order": "desc"
}
}
}
GET category-lookup/_search
{
"size": 4,
"_source": ["id","realId","name","hierarchyPath"],
"query": {
"match_all": {}
},
"sort": {
"_script": {
"type": "number",
"script": {
"lang": "painless",
"source": "doc['hierarchyPath.keyword'].value.length()"
},
"order": "desc"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment