Can I sort results by price and take sold out product to last of results?

I have a problem that is I want to sort product by price (desc) and want sold out product shows at the last of results like below.

{
    "price": 1000
    "inventory": 2
}
{
    "price": 500
    "inventory": 10
}
{
    "price": 200
    "inventory": 1
}
{
    "price": 30
    "inventory": 5
}
{
    "price": 1500
    "inventory": 0
}
{
    "price": 900
    "inventory": 0
}

I try to use multi-fields sorting, but it's not working.

If I want to do like this, what should I do?

Thanks for your helps^^

I wonder if function_score would help you.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.