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

Filter & facet counts in search endpoint #569

Open
joepio opened this issue Jan 26, 2023 · 0 comments
Open

Filter & facet counts in search endpoint #569

joepio opened this issue Jan 26, 2023 · 0 comments

Comments

@joepio
Copy link
Member

joepio commented Jan 26, 2023

While searching, I'd like to see how many instances are available of something if I turn on a specific filter. This is useful for answering questions like:

  • How many books are in the horror genre? And how many in sci-fi?
  • Which prices do products in my query have? How are they distributed?

Ideally these are returned in a counts object or something similar. In meilisearch you can select which properties you want to count by setting facets. This could be a query param for the endpoint.

What meilisearch does: in its response:

  "facetDistribution": {
    "genres": {
      "action": 273,
      "animation": 118,
      "adventure": 132,
      "fantasy": 67,
      "comedy": 475,
      "mystery": 70,
      "thriller": 217
    }
  }

It looks like Tantivy has very powerful Aggregations, even support for elastic JSON aggerations (e.g. averages with specific ranges). However, it does seem to require fast fields for aggregations, which (I think) excludes JSON fields.

I think we need FacetCollector and their counts for counting. But here, too, we seem to know the schema beforehand, so again, I don't know how it deals with JSON fields.

If that doesn't work, we could maybe have a function that iterates over user's Classes, and adds schema for each property. That way we could still add the count fields.

UPDATE: It's working on the main branch of tantivy now!

Also, there are histograms quickwit-oss/tantivy#1900

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