Variant as Child of Parent Strategy
This strategy relies on the fact that variants will be indexed as children for their parent product/bundle/package using the hawk_child_attributes
JSON property.
The properties decorated with [IncludeInHawksearch]
attribute will be the ones that are indexed for each variant residing below hawk_child_attributes
. The product itself is, of course, indexed.
To use this indexing strategy, set variantindexingstrategy to “VariantAsChildOfParent“ in Web.config.
<hawksearch ...
variantindexingstrategy="VariantAsChildOfParent"
</hawksearch>
Example:
[IncludeInHawksearch]
public virtual string Color { get; set; }
The “Color” property will be included in the variant indexed under hawk_child_attributes
.
Convention
Every field that will be equivalent to a variant property shall be prefixed by “Child_” in Hawksearch. Also, it will have the “Is Child Field?” flag set to “ON”
Example:
For →
[IncludeInHawksearch]
public virtual string Color { get; set; }
we have Child_Color
For →
we have Child_Size
Default Fields
These fields are always included in indexing (can be found here)
Child_DisplayName
Child_Code
Child_Url
Considerations
Variant Indexing is unavailable under this strategy.
AddHawksearchVariantIndexing
will throw aNotSupportedException
if attempted to be used inside chain initialization. Also,VariantsIndexingHandler
andVariantsIncrementalIndexingHandler
pipes will be rendered useless and throw exceptions.Price and inventory indexing options from Web.config will have no effect, because Variant Indexing is unavailable.
Indexing Setup Example: Optimizely Foundation
A full version of the HawksearchInitialization
class used to set up indexing on the Optimizely Foundation solution can be found below: