mardi 3 octobre 2017

Get Random Docs from Elastic search results

I'm looking to find a solution to getting three random items from Elastic search results, I mean when I'm looking for some result according to results ( my search type is "term") Elastic search return three random for me.

As a example I want to get three random Doc form my index where it's price is 20.

GET /my_store/products/_search
{
    "query" : {
        "constant_score" : { 
            "filter" : {
                "term" : { 
                    "price" : 20
                }
            }
        }
    }
}

I'm looking for a random fair , I mean If I have 90 Docs in my index after running 30 times , almost all Docs come in the results.




Aucun commentaire:

Enregistrer un commentaire