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

feat: expose all available terms #2097

Closed

Conversation

scottlepp
Copy link

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.

@abhinavdangeti
Copy link
Member

Thanks for this contribution @scottlepp , the team will review soon.

@abhinavdangeti abhinavdangeti added this to the v2.5.0 milestone Nov 11, 2024
@@ -133,6 +133,17 @@ func (tf *TermFacets) Terms() []*TermFacet {
return tf.termFacets
}

func (tf *TermFacets) AvailableTerms() []*TermFacet {
Copy link
Member

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.

Copy link
Author

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

Copy link
Contributor

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?

Copy link
Author

@scottlepp scottlepp Nov 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Terms() func returns termFacets, which is empty. However you can see the termsLookup contains the terms.

I'm faceting on a field that is a string array.

image

Copy link
Contributor

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.

Copy link
Contributor

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).

Copy link
Author

@scottlepp scottlepp Nov 12, 2024

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!

@abhinavdangeti abhinavdangeti removed this from the v2.5.0 milestone Nov 12, 2024
@abhinavdangeti
Copy link
Member

@CascadingRadium would you take a look into the situation here and see if this is necessary.

@abhinavdangeti
Copy link
Member

Thanks @tylerkovacs for helping out on this one!

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

Successfully merging this pull request may close these issues.

4 participants