New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Seeded random ordering (Feature request) #1170
Comments
I'm really interested in this, did someone try to implement this? |
I discussed this briefly with kimchy at the time and his feedback was that it wouldn't be hard to do. Definitely a great feature candidate. |
Cool! I'll try that. |
Has this been implemented into the current version of ES yet? |
@uboness can we pull your latest commit in for this? |
This would be great if it were added. |
BUMP++ |
* can be used to return matching results in random order Closes #1170
random order is now supported as part of the new function score queries. request example: curl -XGET 'localhost:9200/_search' -d '{
"query": {
"function_score" : {
"query" : { "match_all": {} },
"random_score" : {}
}
}
}'; or with a seed (for near-consistent pagination): curl -XGET 'localhost:9200/_search' -d '{
"query": {
"function_score" : {
"query" : { "match_all": {} },
"random_score" : { "seed" : 1376773391128418000 }
}
}
}'; Check out more on function score queries here: #3423 |
This is immensely helpful. I hope we'll see this in v0.90.4 in a matter of days... |
@emptyflask can you tell us a bit about your actual usecase for this? I am very curious and it would be good to have a couple of usecases on the reference documenation |
@s1monw I'm currently doing this with Solr, and it's the one thing that's tying up my migration to ES on that app. There are a few thousand user-submitted ideas that receive votes from other users, so to give every idea an equal chance of showing up on the first page, we want the default view to be randomly sorted, yet paginated and consistent for each user. Using the current user's id as a random seed solves this problem nicely. |
👍 10 points for @uboness |
👍 Will this make it into 0.90.4? |
@brupm it's already pushed to 0.90 branch so yes it will be in 0.90.4 |
Awesome feature, thx! Another use-case is a Wikipedia-like random page - coupled to some search criteria (to avoid low interest pages) it's much faster than querying the DB for a random ID. |
@s1monw Any idea when 0.90.4 will be released? Thanks! |
we plan to release 0.90.4 early next week. |
"sort": [ Is not working :-( |
@dctdct This is the way you should do it: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html |
Maybe this is a bug with the php client but passing this query as array doesn't work. $json = '{
|
How to iterate every items in each page with the random score function? |
Same way you would iterate over any other set of results. The function
|
* can be used to return matching results in random order Closes elastic#1170
@dctdct for PHP use |
Sweet! thanks @uboness |
Implementation of random result ordering with optional seed allowing for recreation of random order i.e. across "pages" when using pagination (from, size).
The text was updated successfully, but these errors were encountered: