Hi,
I have setup a catalog search using a Product entity and related Segment entities. So each product can have multiple Segments associated with it. The segment entitiy has a property called Applications that holds a list of string values and some other properties not relevant to this question. In order to search for Products based on the Segment.Applicaitons values I have added a computed property to Product that holds all values of the Applications property of all it's related Segments. So this is just an array of all string values of the related Segment.Applications field. The Product.Applications property just iterates over all related Segments and build a new array of the Segment.Applications. This is then added to the find index. And searching for a value from one of the applications arrayof a segment reults in a list of products as expected. so far so good.
the search fnctionality is pretty strait forward. search for a string, get a list of products as a result, click on a produc to open the Preoduct Details Page that will show all properties and associated Segment information.
the Product.Applications property looks like this:
[Searchable]
[Tokenize]
public IEnumerable<string> Applications => this.GetApplications()
...
public static IEnumerable<string> GetApplications(this IContent content)
{
List<string> result = new List<string>();
var associations = AssociationsRepository.Service.GetAssociations(content.ContentLink);
foreach (var association in associations)
{
if (association.Target.Get<Segment>() is Segment a)
{
result.AddRange(a.Application);
}
}
return result.Distinct();
}
So the issue if have is in updating the find index. Iwould expect that wen I change the value of the Segment.Applications, this will reflect on the Product.Applications value in the Episerver Find Index. This does not happen. Only when I run the EPiServer Find Content Indexing Job the Product.Applications values are updated with the correct values.
My question is: Is there a way to update the Product.Applications values when the Segment.Applications is changed immediately and without running the EPiServer Find Content Indexing Job every time?
One thing to note is that the catalog is imported using the episerver xml import. and I tried to setup a convenition on the Product.Applicaitons field, but that diddn't help. something like:
ForInstancesOf<Product>().IncludeField(x => x.Applications);
thnx
Pierre