Better extensibility options for Search V2 Indexing
We have a requirement on our project that requires us to change the behavior of the search indexing v2. In trying to do so, our development team ran into an issue where the class we needed to extend was not extensible (internal, sealed, or non overrideable methods).
Basically what we are trying to do is remove the condition that excludes child products when fetching indexable products that is in line 896 of class Insite.Search.Shared.DocumentTypes.Product.Index.SearchV2.Models.Product (this is in version 5.2.2412.1705)
What we would like to see changed is:
1 - Make the SearchV2.Models.Product public instead of internal and remove the sealed keyword (and do the same for other classes in the SearchV2 and SearchV2.Models namespaces)
2 - If possible, move the lines from 893 to 904 to a virtual method so we can override it - specifically this code:
var indexableProducts = products
.Except(inactiveStyleParents)
.Where(p =>
p.StyleParentId is null
&& (
!p.IsDiscontinued
|| (productIdsWithQuantityOnHand.Contains(p.Id) && p.TrackInventory)
)
&& p.IsActive
&& p.IndexStatus != 2
)
.ToArray();
And it's not really just about this particular piece of code - in that class the entire ReadFromDatabase method has a lot of logic in it, is there any way to break some of that apart into virtual methods, or handler chains / pipelines and make it extensible?
3 - Make the constructor of class Insite.Search.Shared.DocumentTypes.Product.Index.SearchIndexableProduct public instead of internal
Without these extension points, we are currently forced to copy / paste a lot of classes from base code, and slightly modify a few of them, in order to achieve the desired functionality. Attached is a screenshot from our pull request showing all of the files we had to copy - the only ones we actually change are the ones highlighted in red.
And again, this is not just about our specific requirement, but more of a request to open the entire Search V2 Indexing architecture to be more extensible. Right now it's pretty "locked down"

-
Thank you for submitting this request!
The design of Search v2 is that the base code produces a default result that can be then modified by partners before uploading to Elasticsearch. This method has corrected an issue in Search V1 where partners could modify the database query in unpredictable ways.
We saw making changes or bugfix in the base code previously in v1 was much more likely to break compatibility with partner customization than we've seen in v2.
Understanding of Impact - Based on the current feedback it sounds like while you are able to create the customization in the existing framework you find that it is cumbersome and taking more time/effort than desired to meet project needs.
If I have misunderstood the impact or you would like to include additional details please feel free to update this request.