question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FacetedSearch's facets property has limited amount of buckets

See original GitHub issue

I’ve been using the FacetedSearch functionality successfully. All seems to be working well. The facets property is added to the response returned from the FacetedSearch object. I am able to access a dictionary with lists of buckets (each with appropriate tuple of key, document count and flag).

The problem is that there seems to be a hard limit on the amount of “buckets” (exactly 10 or less). I’m not referring to the results per facet—just the total amount of buckets.

Example Lets assume a search query generates 300 total hits spread over 13 categories for a particular query.

response = blog_search.execute()

total_hit_count = response.hits.total  # 300
accumulated_facets_hit_count = 0
category_count = 0

for category, hit_count, is_selected in response.facets.category:
    accumulated_facets_hit_count += hit_count
    category_count += 1

When checking the results we have the following unexpected results:

 # This will give `category_count 10` instead of expected `category_count 13`
print('category_count: ', category_count)

# This will give `False` instead of expected `True` 
print(accumulated_facets_hit_count == total_hit_count)

Is there a way to increase the limit of amount of buckets?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
WisdomPillcommented, Jan 28, 2018

Ops… I forgot an example on how to set the size parameter on any other parameter as well

from elasticsearch_dsl import TermsFacet

tf = TermsFacet(fields='text', size=10)
print(tf.get_aggregation())

Hope this helps.

1reaction
atlasstrategiccommented, Jan 28, 2018

@WisdomPill thank you for your comments. Yeap, according to the docs there exists such a size option.

to define how many term buckets should be returned out of the overall terms list

For my use-case, all search results are grouped within the resulting buckets (showing the top 5 results per bucket). Currently, if the search query produces greater than 10 buckets, some buckets are left out and the user can not see the results related to those buckets. For example, imagine a search produces results within 20 countries. Where a bucket represents a country, the user will only see 10 counties to facet on instead of 20.

Maybe It would be useful to be able to increase the size parameter for TermsFacet?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bucket search - facets filter limited to 10 results
Been digging around how to get more than 10 results for each facet filter and can't find any setting to do so -...
Read more >
Elasticsearch bucket aggregations and faceted navigation
A step by step tutorial for using Elasticsearch bucket aggregations to implement faceted navigation a.k.a. facets.
Read more >
JSON Facet API | Apache Solr Reference Guide 8.1
Faceted search is about aggregating data and calculating metrics about that data. ... Number of buckets beyond the limit to internally request from...
Read more >
Faceted Search widget - ServiceNow Docs
The Faceted Search widget displays search results and search facets defined for a search source. The Faceted Search widget enables end users ...
Read more >
$facet (aggregation) — MongoDB Manual
Multi-faceted aggregations provide multiple filters and categorizations to guide data browsing and analysis. Retailers commonly use faceting to narrow search ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found