Skip to content
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

Add _random_docs?limit=5 #1

Open
fabien opened this issue Dec 19, 2011 · 2 comments
Open

Add _random_docs?limit=5 #1

fabien opened this issue Dec 19, 2011 · 2 comments

Comments

@fabien
Copy link

fabien commented Dec 19, 2011

I think it would be useful to be able to retrieve multiple random docs, limited by a certain amount of documents. By default it should probably be just 5 or something, because it could get somewhat inefficient with a high number of docs. Returned docs should be unique. Order could be random too.

Now that I think about it, wouldn't it make sense to be able to get random entries from a view (instead)?

@benoitc
Copy link
Owner

benoitc commented Dec 19, 2011

Ideas of views are interresting, it would speed a lot the thing in some cases where there is a need to filter results.

having something like:

 GET /<db>/_random_doc?filter=_view&view=DName/VName 

would works. Difference with the filter is that you can't change it in real time, but it would be definitly faster.

About the limit, the only efficient way I see to that is pre-generating N randoms number where N < number of docs and return random docs in order. I think it could work.

@benoitc
Copy link
Owner

benoitc commented Dec 19, 2011

the _view filter has been added to last head.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants