@Sean_Story
{
"query": {
"bool": {
"must": {
"function_score": {
"boost_mode": "sum",
"score_mode": "sum",
"query": {
"bool": {
"must": [
{
"bool": {
"should": [
{
"multi_match": {
"query": "tshirt",
"minimum_should_match": "1<-1 3<49%",
"type": "cross_fields",
"fields": [
......
]
}
}
]
}
}
]
}
},
"functions": [
{
"script_score": {
"script": {
"source": "Math.max(_score * ((0.2 * Math.max(0.0001, Math.log(Math.max(0.0001, (doc.containsKey(\"rank.float\") && !doc[\"rank.float\"].empty ? doc[\"rank.float\"].value + 1 : 1)))))) - _score, 0)"
}
}
}
]
}
},
"filter": {
"bool": {
"must": [
{
"terms": {
"company_id.enum": [
"68036",
"67900",
"67758",
"67735",
"68639",
"68530",
"40834",
"67665",
"68501",
"68479",
"68910",
"68333",
"67757",
"67840",
"68920",
"68460",
"68832",
"68534",
"68615",
"68361",
"67868",
"68387",
"67819",
"68351",
"68538",
"68256",
"67745",
"68317",
"68293",
"68292",
"68343",
"68518",
"67718",
"68694",
"68162",
"68816"
]
}
}
]
}
}
}
},
"sort": [
{
"_score": "desc"
},
{
"_doc": "desc"
}
],
"highlight": {
"fragment_size": 300,
"type": "plain",
"number_of_fragments": 1,
"order": "score",
"encoder": "html",
"require_field_match": false,
"fields": {}
},
"size": 0,
"from": 0,
"timeout": "30000ms",
"_source": [
"id"
],
"aggs": {
"group": {
"terms": {
"field": "company_id.enum",
"size": 5,
"order": {
"top_hit": "desc"
}
},
"aggs": {
"group_hits": {
"top_hits": {
"size": 5,
"sort": [
{
"_score": "desc"
}
],
"highlight": {
"fragment_size": 300,
"type": "plain",
"number_of_fragments": 1,
"order": "score",
"encoder": "html",
"require_field_match": false,
"fields": {}
}
}
},
"top_hit": {
"max": {
"script": {
"source": "_score"
}
}
}
}
},
"estimated_total_groups": {
"cardinality": {
"field": "company_id.enum"
}
}
}
}
and
{
"query": {
"bool": {
"must": {
"function_score": {
"boost_mode": "sum",
"score_mode": "sum",
"query": {
"bool": {
"must": [
{
"bool": {
"should": [
{
"multi_match": {
"query": "tshirt",
"minimum_should_match": "1<-1 3<49%",
"type": "cross_fields",
"fields": [
......
]
}
}
]
}
}
]
}
},
"functions": [
{
"script_score": {
"script": {
"source": "Math.max(_score * ((0.2 * Math.max(0.0001, Math.log(Math.max(0.0001, (doc.containsKey(\"rank.float\") && !doc[\"rank.float\"].empty ? doc[\"rank.float\"].value + 1 : 1)))))) - _score, 0)"
}
}
}
]
}
},
"filter": {
"bool": {
"must": [
{
"terms": {
"company_id.enum": [
"68036",
"67900",
"67758",
"67735",
"68639",
"68530",
"40834",
"67665",
"68501",
"68479",
"68910",
"68333",
"67757",
"67840",
"68920",
"68460",
"68832",
"68534",
"68615",
"68361",
"67868",
"68387",
"67819",
"68351",
"68538",
"68256",
"67745",
"68317",
"68293",
"68292",
"68343",
"68518",
"67718",
"68694",
"68162",
"68816"
]
}
}
]
}
}
}
},
"sort": [
{
"_score": "desc"
},
{
"_doc": "desc"
}
],
"highlight": {
"fragment_size": 300,
"type": "plain",
"number_of_fragments": 1,
"order": "score",
"encoder": "html",
"require_field_match": false,
"fields": {}
},
"size": 0,
"from": 0,
"timeout": "30000ms",
"_source": [
"id"
],
"aggs": {
"group": {
"terms": {
"field": "company_id.enum",
"size": 36,
"order": {
"top_hit": "desc"
}
},
"aggs": {
"group_hits": {
"top_hits": {
"size": 5,
"sort": [
{
"_score": "desc"
}
],
"highlight": {
"fragment_size": 300,
"type": "plain",
"number_of_fragments": 1,
"order": "score",
"encoder": "html",
"require_field_match": false,
"fields": {}
}
}
},
"top_hit": {
"max": {
"script": {
"source": "_score"
}
}
}
}
},
"estimated_total_groups": {
"cardinality": {
"field": "company_id.enum"
}
}
}
}