Skip to content

New design for facet abstraction, including querystring and metadata.json #427

@simonw

Description

@simonw

I need a better design for query strings for facets (and for how facets are enabled in metadata.json).

Think of all of the potential kinds of facets:

  • ?_facet_array=tags where tags is a JSON array of values
  • _facet_date=datetimecol - faceted by date part of a datetime
  • _facet_bins=numeric_column - can I do some kind of fancy binning here? Might need to take an argument
  • ?_facet_bins=numeric_column:5 - could be a way to take an argument. We’ll ignore columns with a : in their name.
  • ?_facet_json=jsoncol:jsonpath - could use a JSON path to extract out something to facet on?
  • ?_facet_percentile=numericcolumn - could this work?
  • ?_facet_function=column:sqlfunctionname - maybe this could be interesting? Would allow for e.g. facet by soundex
  • ?_facet_prefix=column:prefix - facet by terms but only if they start with a specific prefix
  • ?_facet_substring=column:3,6 - facet by a substr(column, 3, 6)

Maybe bundling JSON in querystrings is a way to do options?

?_facet_distance={"latitude_column":"x",...}

Could detect values starting with { - and if for some weird reason you have a column starting with that character you can pass this instead: ?_facet_percentile={"column": "{value}"}

This could even be the mechanism that allows us to extend regular facets to support additional options like adding a sum or max to each one.

Problem: it’s not obvious what the name associated with these facets should be. What if one column is faceted multiple times using multiple facet variants?

Maybe just number them? name1=… name2=… etc?

Other option is to use Solr style querystring syntax for notation. Solr does this: ?f.price.facet.range.gap=100&f.age.facet.range.gap=10

So how about this:

?_facet_range=age&_facet_range.span=5

Related: #359

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions