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

Don't suggest column for faceting if all values are 1 #638

Closed
simonw opened this issue Nov 22, 2019 · 3 comments
Closed

Don't suggest column for faceting if all values are 1 #638

simonw opened this issue Nov 22, 2019 · 3 comments

Comments

@simonw
Copy link
Owner

@simonw simonw commented Nov 22, 2019

https://www.niche-museums.com/museums/museums?_facet=wikipedia_url

museums__museums__42_rows

Challenge is how to do this efficiently, since suggested facet queries need to be lightning fast.

@simonw

This comment has been minimized.

Copy link
Owner Author

@simonw simonw commented Nov 22, 2019

We currently use select distinct wikipedia_url ... to suggest facets. This query would only return rows which are represented twice or more:

select
  wikipedia_url, count(*) as n
from
  museums
where
  wikipedia_url is not null
group by wikipedia_url
having n > 1

https://www.niche-museums.com/museums?sql=select%0D%0A++wikipedia_url%2C+count%28*%29+as+n%0D%0Afrom%0D%0A++museums%0D%0Awhere%0D%0A++wikipedia_url+is+not+null%0D%0Agroup+by+wikipedia_url%0D%0Ahaving+n+%3E+1

@simonw

This comment has been minimized.

Copy link
Owner Author

@simonw simonw commented Nov 22, 2019

It's not as simple as that - planet_int should be a suggested facet on https://latest.datasette.io/fixtures/facetable?_facet=planet_int because it returns two filters, even though one of those two is a value of 1. Switching to the new proposed SQL statement misses this.

fixtures__facetable__15_rows_and_museums__select___from__select_id__name__url__address__description__wikipedia_url__photo_url__photo_alt__latitude__longitude__press__permanently_closed__hours_from_museums_order_by_id___limit_0

@simonw simonw closed this in fd137da Nov 22, 2019
@simonw

This comment has been minimized.

Copy link
Owner Author

@simonw simonw commented Nov 22, 2019

Demo: https://latest.datasette.io/fixtures/facetable doesn't suggest distinct_some_null as a facet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.