AI OnAI Off
Hi Johnny,
I think you can use Episerver Find facet to do this.
Example query:
var query = SearchClient.Instance.Search<ProductContent>().Filter(x => x.ParentLink.Match(currentNodeContentLink.ToReferenceWithoutVersion().ToString())).Take(0).TermsFacetFor(x => x.ContentTypeName());
Hope this help
Thank you Binh. This looks like just what i was looking for. I will give it a try!
Hi Binh,
This query does the trick and works for multi level category hierarchies
// use Find to execute search with the content type id set as a facet
var result = SearchClient.Instance.Search<BaseProduct>()
.Filter(x =>
x.Ancestors().Match(currentContent.ContentLink.ToReferenceWithoutVersion().ToString()))
.Take(0).TermsFacetFor(x => x.ContentTypeID.ToString()).GetContentResult();
// extract the content type id's form the result
var types = result.TermsFacetFor(x => x.ContentTypeID.ToString()).Terms;
Yeah, your query works for multi level category hierarchies. Great job!
Hi,
My catalog contains a collection of node content pages and under any node could be a number of different implementations of a product content type.
When loading my category node, I'd like to run a query to return the unique product content types which are children of that node. For example when loading a page, if there are 100 of one product and only 2 of another type, i'd like my query to return the 2 unique types.
My site is using Find so maybe there's a clever option using that.
Has anyone had to do this before?
Thanks in advance!