Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Question about HasChildQuery

Vote:
 

Hello.

Whether is it possible to implement the relation Parent - Child(for example, Has Child Query, elastic) by means of the EPiServer?

Any ideas?

Version EPiServer.Find = 8.9.

Best Regards.

#122615
Jun 08, 2015 11:28
Vote:
 

Hello Dzmitry

Can you explain your requirement? Do you want to find out the parent of the current content item? Or do you want to retrive the child items for the current item?

David

#122618
Jun 08, 2015 12:03
Vote:
 

Hello David,

Requirement:
1. Search parent by a property of a child
For example:
Parent - Child
p1          c1
p1          c2
p1          c3
p2          c4
p3          c5
Child - Property(count)
c1     - 1
c2     - 2
c3     - 3
c4     - 4
c5     - 5
Task: Find all parents, where count of a child > 1(if parent has several children, then return with min count).
Expected result:  p1(c2),p2,p3
Wrong result: p1(c2),p1(c3),p2,p3
Best Regards.
#122619
Jun 08, 2015 12:21
Vote:
 

Hi

Is any ideas? Or was HasChildQuery implemented in other versions EPiServer.Find?

Best Regards

#122687
Edited, Jun 10, 2015 12:04
Vote:
 

Currently Find does not support parent child relations.

/henrik

#122765
Jun 12, 2015 7:28
Vote:
 

Henrik, thank you for your reply.

May be is there another way of grouping products and return a single product from the group during the search?

Best Regards

#122767
Jun 12, 2015 9:08
Vote:
 

Hi Dzmitry

Have you seen Henrik's awesome Nested2Find extension? 

http://www.lindstromhenrik.com/nested-filtering-with-episerver-find/

It may be what you are looking for?

David

#122768
Jun 12, 2015 9:16
Vote:
 

Ps If you simply want to search based on the number of child items you could add a property to your parent model with the the child item count. 

The ChildItemCount will then be indexed and allow you to search on it. 

#122769
Jun 12, 2015 9:18
Vote:
 

Hi,

I wrote this to find Child Categories Having Any products under them for refinement. It may give you some direction.

var childCategoriesHavingProducts = new List<ProductListingNode>();

            var resultSet = this.GetResultSet(catalogContentId).GetContentResult();

            if (resultSet != null && resultSet.Facets != null)
            {
                var catTerms = resultSet.TermsFacetFor(x => x.ParentCategories()).Terms.Where(x => x.Count > 0).Select(x => x.Term);
                childCategoriesHavingProducts = childCategories.Where(x => catTerms.Contains(x.ContentLink.ToString())).ToList();
            }

            return childCategoriesHavingProducts;

Regards

/K

#122770
Jun 12, 2015 9:42
Vote:
 

Hi David
Thank for your replay.

Yes, I seen Henrik's Nested2Find. The post is very good.
I use this idea for similar cases.
But I think, that groups and products should stored as the independent objects.

"Ps If you simply want to search based on the number of child items you could add a property to your parent model with the the child item count.
The ChildItemCount will then be indexed and allow you to search on it."

Unfortunately, but I need get part of the group objects.(not the all products for group)

I use the custom implementation for HasChildQuery. Can this affect performance of Epi Find?

#122820
Jun 16, 2015 9:49
Vote:
 

Hi Khan,
Thank your for your replay.

I think, the search for all groups in index and then the filtering on server side will work slower than using EpiFind with custom query(HasChildQuery).
May be am I wrong?

#122824
Jun 16, 2015 9:55
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.