You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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!
The text was updated successfully, but these errors were encountered:
AlexBitsTech
changed the title
How to implement more facets (avergae, sum, ...)
How to implement more facets (average, sum, ...)
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!
The text was updated successfully, but these errors were encountered: