This query seems like it should work, but returns "-1" for the first position of the sort on all results:
"sort": [
-1,
9678,
8
]
the query (skuid_text is indexed as a 'keyword' type, and I have verified that the result set includes the SKUs specified in sortOrder):
{
"size" : "50",
"_source": ["skuid", "name", "sort_priority","sales"],
"sort" : [
{
"_script": {
"type": "number",
"script": {
"inline" : "params.sortOrder.indexOf(doc['skuid_text'].value)",
"params": {
"sortOrder": [
"CELCO2017L",
"CELCO2017G",
"S21024",
"WED419",
"WED420",
"SOLS2622",
"FDOR2124",
"FDOR2125",
"S21023",
"CELCO2005L",
"CELCO2005G",
"S21022",
"10171",
"10172",
"FDO4124P",
"WED35",
"WED37",
"S2917",
"CELCO2003L",
"CELCO2003G",
"S2769",
"S2932",
"S2936",
"FADRQKE1006W",
"WED306",
"WED307",
"CLAD30DE",
"CELCO2004L",
"CELCO2004G",
"SOLS2466"
]
}
},
"order": "asc"
}
},
{ "sort_priority" : {"order" : "asc"}},
{ "sales" : "desc" }
],
"query" :{
"bool" : {
"must" : [
{
"term" : {
"category_codes" : "IRJB"
}
}
]
}
},
"aggs" : {
"size_apparel" : {
"terms" : {
"field" : "size_apparel"
}
},
"color" : {
"terms" : {
"field" : "color"
}
},
"price" : {
"range" : {
"ranges" : [
{
"to" : 20
},
{
"from" : 20,
"to" : 50
},
{
"to" : 100,
"from" : 50
},
{
"from" : 100,
"to" : 200
},
{
"from" : 200
}
],
"field" : "price"
}
},
"category" : {
"terms" : {
"field" : "category"
}
},
"birthstone" : {
"terms" : {
"field" : "birthstone"
}
},
"size_jewelry" : {
"terms" : {
"field" : "size_jewelry"
}
},
"recipient" : {
"terms" : {
"field" : "recipient"
}
},
"occasion" : {
"terms" : {
"field" : "occasion"
}
}
}
}
I have tried both doc['skuid_text'].value and doc['skuid_text']