Hi,
I want to create a promotional box in my marketplace, with the top rated articles. I dont want always to be the same articles, so i want them be shuffled a little by multiplying the article avg rate by a random number between (+1,1 - 0,9).
Query : match-all, so scorings comes as nulls.
Thanks in advance!
Welcome to our community! ![]()
If you aren't scoring them and you need to use the match all query then you need to do this in your code.
1 Like
do what??
Thanks!
I think I got it:
GET /search-service/_search
{
"query": {
"match_all": {}
},
"sort": [
{
"_script": {
"script": {
"lang": "painless",
"source": "def randomFactor = (Math.random() * 0.2) + 0.9; return doc['service_valuation_media'].value * randomFactor;"
},
"type": "number",
"order": "desc"
}
}
],
"_source": true
}
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.