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

new more efficient way to calculate facets #2

Open
punkish opened this issue Oct 19, 2020 · 0 comments
Open

new more efficient way to calculate facets #2

punkish opened this issue Oct 19, 2020 · 0 comments
Labels
RFC request for comments

Comments

@punkish
Copy link
Owner

punkish commented Oct 19, 2020

I am experimenting with calculating facets, and in a quest to make them more useful as well as the calculation more performant, I have implemented the following – rather than calculating and sending back the entire result set for each facet (the trailing end of which not only likely doesn't get used by the user, it is also likely mostly bogus because of dodgy data), I am retrieving and sending only the top 50 rows of each. You can see the result at http://test.zenodeo.org/v3/treatments?$facets=true

I use SQL something like so (example below for journalTitle)

SELECT journalTitle, count FROM (
    SELECT journalTitle, Count(journalTitle) AS count 
    FROM treatments 
    WHERE journalTitle != '' 
    GROUP BY journalTitle
    HAVING count > 100 
    ORDER BY count DESC 
    LIMIT 50
)  
ORDER BY journalTitle ASC;

Please send me your rant or rave about the above technique.

attn: @tcatapano @teodorgregoriev @mguidoti
cc: @myrmoteras

@punkish punkish added the RFC request for comments label Oct 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFC request for comments
Projects
None yet
Development

No branches or pull requests

1 participant