-
Notifications
You must be signed in to change notification settings - Fork 686
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
feat: expose all available terms #2097
feat: expose all available terms #2097
Conversation
Thanks for this contribution @scottlepp , the team will review soon. |
@@ -133,6 +133,17 @@ func (tf *TermFacets) Terms() []*TermFacet { | |||
return tf.termFacets | |||
} | |||
|
|||
func (tf *TermFacets) AvailableTerms() []*TermFacet { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you add a supporting unit test for this please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi @abhinavdangeti added a test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@scottlepp Could you accomplish what you need with the existing Terms()
func on TermFacets
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems odd, I'm having trouble seeing how termFacets
and termLookup
could be out of sync.
termLookup
is only referenced in Add()
. Add()
accumulates terms into both termLookup
and termFacets
so they should be consistent.
I've been using Terms()
for years for the exact use case desribed in this PR and have never run into this condition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just remembered that there are some other methods that change termFacets
. Fixup()
and TrimToTopN()
can both remove (or entirely truncate) the termFacets
slice.
I'm not that familiar with how these functions are called but, if I had to guess, it might only happen when the size of the facet request is very small (or zero).
bleve.NewFacetRequest("foo", 0)
As an aside, there doesn't appear to be a validation on the size of the facet request so perhaps there's a good reason to allow zero (I can't think of one, but again I'm only passingly familiar with the bleve code base).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tylerkovacs you're right. the limit was defaulting to 0. Closing this. Sorry for the noise!
@CascadingRadium would you take a look into the situation here and see if this is necessary. |
Thanks @tylerkovacs for helping out on this one! |
The lookup contains all possible facets. We would like to expose this to use this as a way to expose all available facets for showing filters.
You can see an example here of what we are doing. We used reflection here for now, but would like to avoid that.