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

How to implement more facets (average, sum, ...) #1812

Open
AlexBitsTech opened this issue Apr 22, 2023 · 0 comments
Open

How to implement more facets (average, sum, ...) #1812

AlexBitsTech opened this issue Apr 22, 2023 · 0 comments

Comments

@AlexBitsTech
Copy link

AlexBitsTech commented Apr 22, 2023

Hello,

I would like to find a way to implement more functionality to the facets (average, sum, ...). I know similar questions have been asked before and the answer has been to look into the facet implementation. So I have!

I've started to look at the code itself to see how I could implement it but I am having issues organizing the steps needed. Here's where I'm at so far in understanding the general steps I would need to follow:
From what I've seen I would need to make a struct like an AvgFacet and a struct that implements the FacetBuilder interface (like an AvgFacetBuilder for example). It seems the averaging logic would have to happen in the UpdateVisitor method of the AvgFacetBuilder (like a rolling average or something). Then I would need to add a flag to the FacetRequest struct to signal I want to use the AvgFacetBuilder which would then be interpreted in the SearchInContext method of the indexImpl struct to add it to the TopNCollector instance created in said method. The Collect method of the TopNCollector instance would call the UpdateVisitor method of the AvgFacetBuilder instance to build up the results. When that is done, the TopNCollector instance calls the AvgFacetBuilder's Results() method via its FacetResults method and this would give me my average via the usual searchResults.Facets["myFacet"] calls. It seems I would also need to modify the FacetResult struct a little to account for my AvgFacetBuilder results.

Of course this is incomplete. There are other blocks I would need to figure out how to implement (in the case of an average I would want to be able to specify 2 fields, one keyword and one numeric, etc etc) but on the whole, is there a general step I am missing?

Thanks in advance for the help!

@AlexBitsTech AlexBitsTech changed the title How to implement more facets (avergae, sum, ...) How to implement more facets (average, sum, ...) Apr 22, 2023
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