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

Feature Request: Random Document Retrieval in GROQ #118

Open
tamas-palecian opened this issue Feb 16, 2024 · 0 comments
Open

Feature Request: Random Document Retrieval in GROQ #118

tamas-palecian opened this issue Feb 16, 2024 · 0 comments

Comments

@tamas-palecian
Copy link

tamas-palecian commented Feb 16, 2024

**Is your feature request related to a problem?
Currently, GROQ lacks a built-in mechanism to fetch documents in a random order.
This limitation complicates scenarios where displaying randomised content is essential, such as in creating dynamic, engaging user experiences. Developers must resort to custom, often cumbersome, workarounds to achieve this functionality, which can increase development time and complexity.

Describe the solution you'd like
Introduce a straightforward method for random sorting within GROQ queries.
This enhancement could be implemented with simple function calls within the order clause, examples of which might include:

order(random()): Orders the results based on a random seed.
order(shuffle()): Shuffles the results to return them in a non-deterministic order.

Describe alternatives you've considered

While custom workarounds exist, they often involve fetching more documents than necessary and shuffling them client-side or periodically updating a "random" field in each document to sort by. These methods are not as efficient or straightforward as having native support for randomness in GROQ queries.

Additional context
Random document retrieval is a common requirement for many applications, including content sites looking to showcase a "random article of the day," e-commerce platforms featuring random products, or any service aiming to enhance user engagement by providing a non-static experience. Native support for this feature in GROQ would significantly simplify development workflows and enable more dynamic content delivery strategies.

@tamas-palecian tamas-palecian changed the title Random Sorting Feature Request: Random Sorting Feb 16, 2024
@tamas-palecian tamas-palecian changed the title Feature Request: Random Sorting Feature Request: Random Document Retrieval in GROQ Feb 16, 2024
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

1 participant